]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Reworking usage of DEBUG and SIMULATE
authorFrank Brehm <frank@brehm-online.com>
Thu, 1 Feb 2024 09:34:10 +0000 (10:34 +0100)
committerFrank Brehm <frank@brehm-online.com>
Thu, 1 Feb 2024 09:34:10 +0000 (10:34 +0100)
bin/manual-backup
bin/pull-known-hosts
bin/start-openfortivpn
bin/update-minecraft-server-jar
bin/update-nextcloud
lib/functions.rc

index 7cf944d13e8fe0867245ec009bdd8a3145695005..5fa3e0b13166dabad67ea6b072d8a8e960f631c6 100755 (executable)
@@ -86,7 +86,7 @@ TAR() {
         cmd+=" >/dev/null 2>&1 || true"
     fi
 
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -174,7 +174,7 @@ get_options() {
     # Note the quotes around `$TEMP': they are essential!
     eval set -- "${tmp}"
     eval_common_options "$@"
-    if [[ "${DEBUG}" == 'y' ]] ; then
+    if [[ "${DEBUG}" ]] ; then
         declare -p REMAINING_OPTS
         declare -p REMAINING_ARGS
     fi
@@ -195,7 +195,7 @@ get_options() {
         exit 2
     fi
 
-    if [[ "${SIMULATE}" != 'y' ]] ; then
+    if [[ -z "${SIMULATE}" ]] ; then
         LOGFILE="${BACKUP_HOSTDIR}/backup.log"
     fi
 }
@@ -371,7 +371,7 @@ do_mysql_backup(){
         cmd+=" --verbose"
     fi
     cmd+=" > \"${dumpfile}\""
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -411,7 +411,7 @@ do_postgres_backup() {
         cmd+=" --verbose"
     fi
     cmd+=" > \"${dumpfile}\""
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
     else
         debug "Executing: ${cmd}"
@@ -438,7 +438,7 @@ do_postgres_backup() {
             cmd+=" --verbose"
         fi
         cmd+=" > \"${dumpfile}\""
-        if [[ "${SIMULATE}" == "y" ]] ; then
+        if [[ "${SIMULATE}" ]] ; then
             info "Executing: ${cmd}"
             continue
         fi
@@ -472,7 +472,7 @@ do_backup_ldap() {
         cmd+=" --verbose"
     fi
     cmd+=" > \"${dumpfile}\""
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
     else
         debug "Executing: ${cmd}"
@@ -499,7 +499,7 @@ do_backup_ldap() {
             cmd+=" --verbose"
         fi
         cmd+=" > \"${dumpfile}\""
-        if [[ "${SIMULATE}" == "y" ]] ; then
+        if [[ "${SIMULATE}" ]] ; then
             info "Executing: ${cmd}"
         else
             debug "Executing: ${cmd}"
@@ -531,7 +531,7 @@ create_checksums() {
         cs_file="backup-checksums.${cs_type}"
         info "Creating '${CYAN}${cs_file}${NORMAL}' ..."
         cmd="${cs_type}sum *.gz > \"${cs_file}\""
-        if [[ "${SIMULATE}" == "y" ]] ; then
+        if [[ "${SIMULATE}" ]] ; then
             info "Executing: ${cmd}"
             continue
         fi
@@ -607,7 +607,7 @@ sync_to_remote() {
         else
             cmd+=" 2>&1 | tee -a \"${LOGFILE}\""
         fi
-        if [[ "${SIMULATE}" == "y" ]] ; then
+        if [[ "${SIMULATE}" ]] ; then
             info "Executing: ${cmd}"
             continue
         fi
index cc084ceb462f9a4ba9023b3a4dba62748dd37c32..c313204dcb42edc6589dc7a7fb47c58d58159d5a 100755 (executable)
@@ -128,7 +128,7 @@ get_options() {
     # Note the quotes around `$TEMP': they are essential!
     eval set -- "${tmp}"
     eval_common_options "$@"
-    if [[ "${DEBUG}" == 'y' ]] ; then
+    if [[ "${DEBUG}" ]] ; then
         declare -p REMAINING_OPTS
         declare -p REMAINING_ARGS
     fi
index 63e74b422a46660728fea99dc6f65bc54ed93b9b..f6c4e465bcb2835cdba575dcd958c75984d3407b 100755 (executable)
@@ -69,7 +69,7 @@ get_options() {
     # Note the quotes around `$TEMP': they are essential!
     eval set -- "${tmp}"
     eval_common_options "$@"
-    if [[ "${DEBUG}" == 'y' ]] ; then
+    if [[ "${DEBUG}" ]] ; then
         declare -p REMAINING_OPTS
         declare -p REMAINING_ARGS
     fi
index cb2fa20e6818475fbdca3e06c905ca5782206167..7a8f0065792a6b72c6d19184a934582ea7afa813 100755 (executable)
@@ -83,7 +83,7 @@ get_options() {
     # Note the quotes around `$TEMP': they are essential!
     eval set -- "${tmp}"
     eval_common_options "$@"
-    if [[ "${DEBUG}" == 'y' ]] ; then
+    if [[ "${DEBUG}" ]] ; then
         declare -p REMAINING_OPTS
         declare -p REMAINING_ARGS
     fi
@@ -237,7 +237,7 @@ do_download() {
     fi
 
     local cmd="curl -o \"${TARGET_JAR}\" -s \"${DOWNLOAD_URL}\""
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
     else
         debug "Executing: ${cmd}"
@@ -260,7 +260,7 @@ check_sha1() {
     info "Checking SHA1 sum integrety of '${CYAN}${TARGET_JAR}${NORMAL}' ..."
 
     if [[ ! -f "${TARGET_JAR}" ]] ; then
-        if [[ "${SIMULATE}" == "y" ]] ; then
+        if [[ "${SIMULATE}" ]] ; then
             debug "Simulation mode - jar file must not exists."
             return 0
         fi
@@ -356,13 +356,13 @@ restart_service() {
     empty_line
     for service in "${services[@]}" ; do
         info "Restarting '${CYAN}${service}${NORMAL}' ..."
-        if [[ "${SIMULATE}" != "y" ]] ; then
+        if [[ -z "${SIMULATE}" ]] ; then
             systemctl restart "${service}"
         fi
         MAIL_BODY+="$( my_date ): Restarted service '${service}'.\n"
     done
 
-    if [[ "${SIMULATE}" != "y" ]] ; then
+    if [[ -z "${SIMULATE}" ]] ; then
         debug "Sleeping for 15 seconds ..."
         sleep 15
     fi
@@ -393,7 +393,7 @@ check_and_send_mail() {
     MAIL_BODY+="With best regards\n\n"
     MAIL_BODY+="Your ${BASE_NAME}"
 
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         local msg="Following mail should be sent:\n"
         msg+="From: <${MAIL_FROM_ADDRESS}>\n"
         msg+="To: <${MAIL_TO_ADDRESS}>\n"
index c393702d0300051b74bd258f8188f6b9bb484d97..3b1b9fb193e5689100328984f8a52b0b5208fb88 100755 (executable)
@@ -88,7 +88,7 @@ get_options() {
     # Note the quotes around `$TEMP': they are essential!
     eval set -- "${tmp}"
     eval_common_options "$@"
-    if [[ "${DEBUG}" == 'y' ]] ; then
+    if [[ "${DEBUG}" ]] ; then
         declare -p REMAINING_OPTS
         declare -p REMAINING_ARGS
     fi
index d2f242d86810ffeca53aad267455cf587486e1e1..879f8391a3ef12f7845f2d98691696f94b75008d 100644 (file)
@@ -29,9 +29,9 @@ STD_USAGE_MSG=$( cat <<-EOF
 
 # Standard global variables
 VERBOSE=""
-DEBUG="n"
-DO_ASK="n"
-SIMULATE="n"
+DEBUG=""
+DO_ASK=""
+SIMULATE=""
 QUIET="n"
 
 LOGFILE=
@@ -191,7 +191,7 @@ eval_common_options() {
         exit 1
     fi
 
-    if [[ "${DEBUG}" = "y" ]] ; then
+    if [[ "${DEBUG}" ]] ; then
         set -x
     fi
 
@@ -203,7 +203,7 @@ eval_common_options() {
         done
     fi
 
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         echo
         echo -e "${CYAN}Simulation mode!${NORMAL}"
         echo "Nothing is really done."
@@ -380,7 +380,7 @@ RM() {
     if [[ "${VERBOSE}" ]] ; then
         cmd="rm --verbose $*"
     fi
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -411,7 +411,7 @@ MKDIR() {
     if [[ "${VERBOSE}" ]] ; then
         cmd="mkdir --verbose $*"
     fi
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -426,7 +426,7 @@ CP() {
     if [[ "${VERBOSE}" ]] ; then
         cmd="cp --verbose $*"
     fi
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -446,7 +446,7 @@ MV() {
     if [[ "${VERBOSE}" ]] ; then
         cmd="mv --verbose $*"
     fi
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -466,7 +466,7 @@ CHOWN() {
     if [[ "${VERBOSE}" ]] ; then
         cmd="chown --verbose $*"
     fi
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -486,7 +486,7 @@ CHMOD() {
     if [[ "${VERBOSE}" ]] ; then
         cmd="chmod --verbose $*"
     fi
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi
@@ -506,7 +506,7 @@ LN() {
     if [[ "${VERBOSE}" ]] ; then
         cmd="ln --verbose $*"
     fi
-    if [[ "${SIMULATE}" == "y" ]] ; then
+    if [[ "${SIMULATE}" ]] ; then
         info "Executing: ${cmd}"
         return
     fi