From 169219bd918b56cbade042cd7c42f81647deb622 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 20 Sep 2018 00:19:59 -0600 Subject: [PATCH] Added cleanup function --- backup.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/backup.sh b/backup.sh index 193298d..1703460 100755 --- a/backup.sh +++ b/backup.sh @@ -89,6 +89,33 @@ function ncMaint { fi } +### cleanup - cleanup files and directories created by this script +function cleanup { + # remove SQL dump file and directory + rm -rf "$sqlDumpDir" >> "$logfile" 2>&1 + # verify directory is gone + checkExist fd "$sqlDumpDir" + checkResult="$?" + if [ "$checkResult" = "0" ]; then + # directory still exists + echo -e "${yellow}${stamp} -- [WARNING] code 111 --${normal}" \ + >> "$logFile" + exitWarn+=('111') + 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 + echo -e "${yellow}${stamp} -- [WARNING] code 5030 --${normal}" \ + >> $"$logFile" + exitWarn+=('5030') + fi +} + ### End of Functions ### @@ -117,6 +144,8 @@ errorExplain[2]="This script MUST be run as ROOT." errorExplain[100]="Could not put NextCloud into Maintenance mode." ### Warning codes & messages +warningExplain[111]="Could not remove temporary directory: ${sqlDumpDir}. Please remove manually." +warningExplain[5030]="Could not remove 503 error page. This MUST be removed manually before NGINX will serve webclients!" warningExplain[5031]="No path to a 503 error page file was specified (-5 parameter missing)" warningExplain[5032]="The specified 503 error page could not be found" warningExplain[5033]="No webroot path was specified (-w parameter missing)"