From 213210eef46a73e24cd8f20c9c2ffdc3739c5747 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 6 Sep 2018 02:37:41 -0600 Subject: [PATCH] Rewrote 503 section to use checkExist --- root/scripts/borgbackup.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/root/scripts/borgbackup.sh b/root/scripts/borgbackup.sh index 59c73ed..1af02f3 100755 --- a/root/scripts/borgbackup.sh +++ b/root/scripts/borgbackup.sh @@ -247,6 +247,36 @@ echo -e "\e[0;33m$sqlDumpDir/$sqlDumpFile\e[0m" | tee -a $logFileVerbose \ ## Find 503 error page and copy to NGINX webroot ## File must be in the same location as this script ## IF file is not found, log warning but continue script +checkExist find warn $err503FullPath +checkResult="$?" +if [ "$checkResult" = "2" ]; then + # file not found, issue warning + echo -e "\e[1;33m--Warning-- The 503 file should be re-created" \ + "ASAP." >> $logFile + echo -e "\e[1;33m--Warning-- Web users will NOT be notified the" \ + "server is down.\e[0m" >> $logFile + echo -e "Script will continue processing..." >> $logFile +else + # file found, copy it to webroot + echo -e "\e[1;36m[`date +%Y-%m-%d` `date +%H:%M:%S`] Copying 503 error" \ + "page to NGINX webroot..." >> $logFile + cp $err503FullPath $webroot/ 2>&1 | tee $logFileVerbose $logFileNormal \ + > /dev/null + # verify copy was successful + checkExist find warn "$webroot/$err503FileName" + checkResult="$?" + if [ "$checkResult" = "2" ]; then + # file not found, issue warning + echo -e "\e[1;33m[`date +%Y-%m-%d` `date +%H:%M:%S`] --Warning--" \ + "There was a problem copying the 503 error page to" \ + "webroot." >> $logFile + echo -e "\e[1;33m--Warning-- Web users will NOT be notified the" \ + "server is down.\e[0m" >> $logFile + echo -e "Script will continue processing..." >> $logFile + fi +fi + + if [ -e $err503FullPath ]; then echo -e "\e[0m[`date +%Y-%m-%d` `date +%H:%M:%S`] Found 503 error" \ "page at:" >> $logFile