From fc0a7c056c356f2959b4f808541e6faffad1cd6e Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 1 Oct 2018 23:10:20 -0600 Subject: [PATCH] Rewrote 503 copy to webroot and verify section. --- backup.sh | 66 ++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/backup.sh b/backup.sh index f47dc79..3c44e3a 100755 --- a/backup.sh +++ b/backup.sh @@ -253,49 +253,41 @@ else >> "$logFile" exitWarn+=('5034') else - # webroot exists - echo -e "${op}${stamp} Using webroot: ${lit}${webroot}${normal}" \ - >> "$logFile" - # Verify 503 existance - checkExist ff "$err503File" - checkResult="$?" - if [ "$checkResult" = "1" ]; then - # 503 file specified could not be found - echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \ + # webroot exists + echo -e "${op}${stamp} Using webroot: ${lit}${webroot}${normal}" \ >> "$logFile" - exitWarn+=('5032') - else + # Verify 503 file existance + checkExist ff "$err503File" + checkResult="$?" + if [ "$checkResult" = "1" ]; then + # 503 file could not be found + echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \ + >> "$logFile" + exitWarn+=('5032') else - # verify provided webroot path exists - checkExist fd "$webroot" - checkResult="$?" - if [ "$checkResult" = "1" ]; then - # webroot directory specified could not be found - echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \ - >> "$logFile" - exitWarn+=('5034') - else - # webroot exists and 503 exists, copy 503 to webroot - echo -e "${op}${stamp} Copying 503 error page to webroot" \ - "${normal}" >> "$logFile" - cp "${err503File}" "$webroot/" >> "$logFile" 2>&1 - copyResult="$?" - # verify copy was successful - if [ "$copyResult" = "1" ]; then - # copy was unsuccessful - echo -e "${info}${stamp} -- [INFO] ${warn503}" \ - "--${normal}" >> "$logFile" - exitWarn+=('5035') - else - # copy was successful - echo -e "${op}${stamp} 503 error page" \ - "copied to webroot${normal}" >> "$logFile" - fi - fi + # 503 file exists and webroot is valid. Let's copy it! + echo -e "${op}${stamp} ${err503File} found.${normal}" >> "$logFile" + echo -e "${op}${stamp} Copying 503 error page to webroot..." \ + "${normal}" >> "$logFile" + cp "${err503File}" "$webroot/" >> "$logFile" 2>&1 + copyResult="$?" + # verify copy was successful + if [ "$copyResult" = "1" ]; then + # copy was unsuccessful + echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \ + >> "$logFile" + exitWarn+=('5035') + else + # copy was successful + echo -e "${info}${stamp} -- [INFO] 503 error page" \ + "successfully copied to webroot --${normal}" >> "$logFile" + fi fi fi fi +### --- End 503 section --- + ### Put NextCloud in maintenance mode #ncMaint on