diff --git a/lehook.sh b/lehook.sh index ff2488f..bb83657 100755 --- a/lehook.sh +++ b/lehook.sh @@ -3,6 +3,17 @@ DIR=$HOME/.lehook configfile=$DIR/config VALIDMODES="deploy|renew|generate|test" +function doinstall() { + echo "Creating hardlinks in $DIR..." + cp -f $0 $DIR/lehook.sh + for x in pre post deploy; do + ln -f $DIR/lehook.sh $DIR/lehook-${x}.sh + done + ln -f $DIR/lehook.sh /usr/local/bin/lehook.sh + echo "Install complete. Files are in $DIR." + echo "Main binary in /usr/local/bin/lehook.sh." +} + function doinit() { mkdir -p $DIR if [[ ! -e $configfile ]]; then @@ -116,7 +127,7 @@ function usage() { echo echo " -c Cron mode - only output if something is done." echo " -f Push out certs even if they haven't changed." - echo " -i Iniitalise new config file in $configfile" + echo " -i Install files in $DIR and generate config if it doesn't exist." echo " -r remotes Only push certs to the given remotes [default: $remotes]" echo " -s services Only restart the given services [default: $services]" echo " -d domain Only push cert for given domain [default: $domains]." @@ -254,6 +265,15 @@ else fi fi +function needsrestart() { + local sname rv + sname=$1 + rv=1 + if [[ $sname == "dovecot" ]]; then + rv=0 + fi + return $rv +} function wait_for_dns_update() { # wait_for_dns_update domain value local ns record @@ -423,6 +443,9 @@ elif [[ $mode == "deploy" ]]; then for s in $services; do if [[ $enabled == *$s* ]]; then reloadcmd=$(echo "$reloadcmd" | sed -e "s/XX/$s/") + if needsrestart $s; then + reloadcmd=$(echo "$reloadcmd" | sed -e "s/reload/restart/") + fi dossh $r $s "$reloadcmd" thisrv=$? rv=$((rv + $thisrv))