diff --git a/seqs/webserver.sh b/seqs/webserver.sh index 7160caa..93e5aa7 100755 --- a/seqs/webserver.sh +++ b/seqs/webserver.sh @@ -36,7 +36,7 @@ step_2() { exe mkdir -p "$siteLetsencryptWww" echo -n "Restarting Nginx ... " - service nginx restart && echo "ok" + exe service nginx restart && echo "ok" saveReturn $? endReturn } @@ -65,7 +65,7 @@ step_4() { addConf "$mariadbConfig" "$mariadbConfigLoc" echo -n "Restarting mysql ... " - service mysql restart && echo "ok" + exe service mysql restart && echo "ok" } mariadbConfigLoc="/etc/mysql/mariadb.conf.d/90-myconfig.cnf" @@ -110,8 +110,8 @@ step_6() { addConf "$phpFpmConfig" "$phpFpmConfigLocation" addConf "$phpCliConfig" "$phpCliConfigLocation" - echo "Restarting ${phpName} ... " - service ${phpName}-fpm restart && echo "ok" + echo -n "Restarting ${phpName} ... " + exe service ${phpName}-fpm restart && echo "ok" } step_10_info() { echo -e "Create mysql database without specific characterset\n"; } diff --git a/sequencer/sequencer.sh b/sequencer/sequencer.sh index 2cbcad7..66c5cc7 100755 --- a/sequencer/sequencer.sh +++ b/sequencer/sequencer.sh @@ -13,6 +13,7 @@ VERSION_MINOR=0 ## Start of generic script part QUIET=0 +DRY=0 VERBOSE=0 ERNO=0 MAX_STEP=255 @@ -25,6 +26,8 @@ helpSequencer() { echo "Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS]" echo echo " [OPTIONS]" + echo " --dry-run, -d : Only print to console what would be done" + echo " ! Attention - Sequence must support this" echo " --help, -h : Display help" echo " --quiet, -q : Don't ask for permission to execute steps" echo " If called without starting step number, only this help is shown" @@ -98,6 +101,11 @@ endReturn() { # if all fails, a log file is created with the conflicts to be resolved by the user addConf() { echo -n "Writing $2 ... " + if [ "$DRY" -ne 0 ] ; then + echo "dry-run" + return 0; + fi + # try writing config directly if [ ! -f "$2" ] ; then echo "$1" > "$2" @@ -336,7 +344,9 @@ showVersion() { exe() { arr=("$@") - if [ $VERBOSE -eq 1 ] ; then + if [ $DRY -ne 0 ] ; then + echo -e "\n-- ${arr[@]}" + elif [ $VERBOSE -eq 1 ] ; then (set -x; "${arr[@]}") else "${arr[@]}" @@ -349,6 +359,11 @@ main() { # options check for arg in "$@" ; do case "$arg" in + --dry-run|-d) # shows what would be done + DRY=1 + QUIET=1 + shift + ;; --help|-h) # show only help displayHelp exit 0; @@ -395,6 +410,14 @@ main() { exit 1; fi fi + + if [ $DRY -ne 0 ] ; then + echo + echo "[WARN] Dry run active." + echo " Printed commands may not be accurate (e.g. quotation incorrect)" + echo " Sequence may ignore dry run" + read -p "Press enter to continue or Ctrl + c to abort" + fi parseAlias