First attempt to include dry run functionality
This commit is contained in:
@@ -36,7 +36,7 @@ step_2() {
|
|||||||
exe mkdir -p "$siteLetsencryptWww"
|
exe mkdir -p "$siteLetsencryptWww"
|
||||||
|
|
||||||
echo -n "Restarting Nginx ... "
|
echo -n "Restarting Nginx ... "
|
||||||
service nginx restart && echo "ok"
|
exe service nginx restart && echo "ok"
|
||||||
saveReturn $?
|
saveReturn $?
|
||||||
endReturn
|
endReturn
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ step_4() {
|
|||||||
addConf "$mariadbConfig" "$mariadbConfigLoc"
|
addConf "$mariadbConfig" "$mariadbConfigLoc"
|
||||||
|
|
||||||
echo -n "Restarting mysql ... "
|
echo -n "Restarting mysql ... "
|
||||||
service mysql restart && echo "ok"
|
exe service mysql restart && echo "ok"
|
||||||
}
|
}
|
||||||
|
|
||||||
mariadbConfigLoc="/etc/mysql/mariadb.conf.d/90-myconfig.cnf"
|
mariadbConfigLoc="/etc/mysql/mariadb.conf.d/90-myconfig.cnf"
|
||||||
@@ -110,8 +110,8 @@ step_6() {
|
|||||||
addConf "$phpFpmConfig" "$phpFpmConfigLocation"
|
addConf "$phpFpmConfig" "$phpFpmConfigLocation"
|
||||||
addConf "$phpCliConfig" "$phpCliConfigLocation"
|
addConf "$phpCliConfig" "$phpCliConfigLocation"
|
||||||
|
|
||||||
echo "Restarting ${phpName} ... "
|
echo -n "Restarting ${phpName} ... "
|
||||||
service ${phpName}-fpm restart && echo "ok"
|
exe service ${phpName}-fpm restart && echo "ok"
|
||||||
}
|
}
|
||||||
|
|
||||||
step_10_info() { echo -e "Create mysql database without specific characterset\n"; }
|
step_10_info() { echo -e "Create mysql database without specific characterset\n"; }
|
||||||
|
@@ -13,6 +13,7 @@ VERSION_MINOR=0
|
|||||||
## Start of generic script part
|
## Start of generic script part
|
||||||
|
|
||||||
QUIET=0
|
QUIET=0
|
||||||
|
DRY=0
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
ERNO=0
|
ERNO=0
|
||||||
MAX_STEP=255
|
MAX_STEP=255
|
||||||
@@ -25,6 +26,8 @@ helpSequencer() {
|
|||||||
echo "Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS]"
|
echo "Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS]"
|
||||||
echo
|
echo
|
||||||
echo " [OPTIONS]"
|
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 " --help, -h : Display help"
|
||||||
echo " --quiet, -q : Don't ask for permission to execute steps"
|
echo " --quiet, -q : Don't ask for permission to execute steps"
|
||||||
echo " If called without starting step number, only this help is shown"
|
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
|
# if all fails, a log file is created with the conflicts to be resolved by the user
|
||||||
addConf() {
|
addConf() {
|
||||||
echo -n "Writing $2 ... "
|
echo -n "Writing $2 ... "
|
||||||
|
if [ "$DRY" -ne 0 ] ; then
|
||||||
|
echo "dry-run"
|
||||||
|
return 0;
|
||||||
|
fi
|
||||||
|
|
||||||
# try writing config directly
|
# try writing config directly
|
||||||
if [ ! -f "$2" ] ; then
|
if [ ! -f "$2" ] ; then
|
||||||
echo "$1" > "$2"
|
echo "$1" > "$2"
|
||||||
@@ -336,7 +344,9 @@ showVersion() {
|
|||||||
|
|
||||||
exe() {
|
exe() {
|
||||||
arr=("$@")
|
arr=("$@")
|
||||||
if [ $VERBOSE -eq 1 ] ; then
|
if [ $DRY -ne 0 ] ; then
|
||||||
|
echo -e "\n-- ${arr[@]}"
|
||||||
|
elif [ $VERBOSE -eq 1 ] ; then
|
||||||
(set -x; "${arr[@]}")
|
(set -x; "${arr[@]}")
|
||||||
else
|
else
|
||||||
"${arr[@]}"
|
"${arr[@]}"
|
||||||
@@ -349,6 +359,11 @@ main() {
|
|||||||
# options check
|
# options check
|
||||||
for arg in "$@" ; do
|
for arg in "$@" ; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
|
--dry-run|-d) # shows what would be done
|
||||||
|
DRY=1
|
||||||
|
QUIET=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--help|-h) # show only help
|
--help|-h) # show only help
|
||||||
displayHelp
|
displayHelp
|
||||||
exit 0;
|
exit 0;
|
||||||
@@ -395,6 +410,14 @@ main() {
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
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
|
parseAlias
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user