diff --git a/lehook.sh b/lehook.sh index fec8bbb..02d10d8 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 @@ -29,14 +40,8 @@ EOF else echo "$configfile already exists." fi - 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 "Init complete. Files are in $DIR." - echo "Main binary in /usr/local/bin/lehook.sh." + doinstall + echo "Init complete" } function out() { @@ -99,7 +104,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]."