From 370d9d34a72761a7defd9838c7a8129d96786150 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sun, 30 Sep 2018 20:00:39 -0600 Subject: [PATCH] Added cleanup skip 503 if null --- backup.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/backup.sh b/backup.sh index 6580c7c..e2183ca 100755 --- a/backup.sh +++ b/backup.sh @@ -89,7 +89,7 @@ function ncMaint { ### cleanup - cleanup files and directories created by this script function cleanup { - # remove SQL dump file and directory + ## remove SQL dump file and directory rm -rf "$sqlDumpDir" >> "$logFile" 2>&1 # verify directory is gone checkExist fd "$sqlDumpDir" @@ -103,18 +103,22 @@ function cleanup { >> "$logFile" fi - # remove 503 error page - rm -f "$webroot/$err503File" >> "$logFile" 2>&1 - # verify file is actually gone - checkExist ff "$webroot/$err503File" - checkResult="$?" - if [ "$checkResult" = "0" ]; then - # file still exists - exitWarn+=('5030') - else - # file removed - echo -e "${bold}${cyan}${stamp} Removed 503 error page from webroot" \ - "${normal}" >> "$logFile" + ## remove 503 error page + # check if 503 page was specified to begin with + if [ -n "$err503File" ]; then + # proceed with cleanup + rm -f "$webroot/$err503File" >> "$logFile" 2>&1 + # verify file is actually gone + checkExist ff "$webroot/$err503File" + checkResult="$?" + if [ "$checkResult" = "0" ]; then + # file still exists + exitWarn+=('5030') + else + # file removed + echo -e "${bold}${cyan}${stamp} Removed 503 error page" \ + "from webroot${normal}" >> "$logFile" + fi fi }