#!/bin/bash

# This script can be added as a --deploy-hook to the certbot renewal command.
# If you have sudo access set up correctly, this step can be done automatically on renewal.
# See notes in convert-https-cert.sh

# See: https://stackoverflow.com/questions/29832037/how-to-get-script-directory-in-posix-sh/29835459#29835459

full_progdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
#full_parentdir=${full_progdir%/*}

# source gs3-setup.sh then stop tomcat, install the cert, then restart tomcat
cd "$full_progdir" \
    && . ./gs3-setup.sh  \
    && if [ -f ant-stop-with-exts.sh ] ; then ./ant-stop-with-exts.sh ; else ant stop ; fi \
    && ant install-https-cert-linux-nopwd  \
    && if [ -f ant-start-with-exts.sh ] ; then ./ant-start-with-exts.sh ; else ant start ; fi

