From 90772f07a9206ebc9363d91198eec8df71825178 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 19 Sep 2018 21:53:34 -0600 Subject: [PATCH] Added 503 error page check --- backup.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index 0e99b2e..6e4b514 100755 --- a/backup.sh +++ b/backup.sh @@ -88,6 +88,7 @@ unset logFileVerbose unset borgCreateParams unset borgPruneParams unset sqlDumpDir +unset 503Location errorExplain=() exitWarn=() @@ -105,7 +106,7 @@ if [ -z $1 ]; then fi # use GetOpts to process parameters -while getopts ':l:nv' PARAMS; do +while getopts ':l:nv5' PARAMS; do case "$PARAMS" in l) # use provided location for logFile @@ -119,6 +120,10 @@ while getopts ':l:nv' PARAMS; do # verbose logging (script errors, Borg details) logLevel="verbose" ;; + 5) + # 503 error page location + 503Location="${OPTARG}" + ;; ?) # unrecognized parameters trigger scriptHelp scriptHelp @@ -165,6 +170,30 @@ echo -e "${normal}${stamp} mySQL dump file will be stored at:" \ | tee -a "$logFileNormal" "$logFileVerbose" +### 503 error page + +# Verify 503 existance +if [ -z "$503Location" ]; then + # no 503 file has been provided + echo -e "${bold}${yellow}${stamp} -- [WARNING] No 503 error page file" \ + "specified --${normal}" >> "$logFile" + echo -e "${bold}${yellow} Web users will NOT be informed the server" \ + "is down." | tee -a "$logFileNormal" "$logFileVerbose" + exitWarn+=('5031') +else + checkExist "$503Location" + checkResult="$?" + if [ "$checkResult" = "1" ]; then + # 503 file specified could not be found + echo -e "${bold}${yellow}${stamp} -- [WARNING] 503 error page file" \ + "specified could not be found --${normal}" >> "$logFile" + echo -e "${bold}${yellow} Web users will NOT be informed the server" \ + "is down." | tee -a "$logFileNormal" "$logFileVerbose" + exitWarn+=('5032') + else + # 503 file found, copy it to the webroot + + # This code should not be executed since the 'quit' function should terminate # this script. Therefore, exit with code 99 if we get to this point. exit 99