func cleanup to remove script working files
This commit is contained in:
parent
e85aa37553
commit
08ab44ce84
@ -34,9 +34,32 @@ badParam () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
cleanup () {
|
||||||
|
# cleanup 503 if copied
|
||||||
|
if [ $err503Copied -eq 1 ]; then
|
||||||
|
if ! rm -f "$webroot/$err503File" 2>>"$logFile"; then
|
||||||
|
printf "${warn}[%s] -- [WARNING] Could not remove 503 error page." \
|
||||||
|
"$(stamp)" >> "$logFile"
|
||||||
|
printf " Web interface will not function until this file is " \
|
||||||
|
>> "$logFile"
|
||||||
|
printf "removed --${norm}\n" >> "$logFile"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ $sqlCopied -eq 1 ]; then
|
||||||
|
if ! rm -rf "$sqlDumpDir" 2>>"$logFile"; then
|
||||||
|
printf "${warn}[%s] -- [WARNING] Could not remove temporary " \
|
||||||
|
"$(stamp)" >> "$logFile"
|
||||||
|
printf "SQL dump directory at $sqlDumpDir. " >> "$logFile"
|
||||||
|
printf "Remove manually to free up space.${norm}\n" >> "$logFile"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
exitError () {
|
exitError () {
|
||||||
printf "${err}[%s] -- [ERROR] %s: %s --${norm}\n" \
|
printf "${err}[%s] -- [ERROR] %s: %s --${norm}\n" \
|
||||||
"$(stamp)" "$1" "$2" >> "$logFile"
|
"$(stamp)" "$1" "$2" >> "$logFile"
|
||||||
|
cleanup
|
||||||
exit "$1"
|
exit "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +102,8 @@ logFile="$scriptPath/${scriptName%.*}.log"
|
|||||||
borgCreateParams='--stats'
|
borgCreateParams='--stats'
|
||||||
borgPruneParams='--list'
|
borgPruneParams='--list'
|
||||||
configDetails="$scriptPath/seafbackup.details"
|
configDetails="$scriptPath/seafbackup.details"
|
||||||
|
err503Copied=0
|
||||||
|
sqlCopied=0
|
||||||
|
|
||||||
# 503 related
|
# 503 related
|
||||||
use503=0
|
use503=0
|
||||||
@ -286,6 +311,8 @@ if [ $use503 -eq 1 ]; then
|
|||||||
else
|
else
|
||||||
printf "${ok}[%s] -- [SUCCESS] 503 error page copied --${norm}\n" \
|
printf "${ok}[%s] -- [SUCCESS] 503 error page copied --${norm}\n" \
|
||||||
"$(stamp)" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
|
# set cleanup flag
|
||||||
|
err503Copied=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -348,7 +375,8 @@ if ! mysqldump -h"${sqlServer}" -u"${sqlUser}" -p"${sqlPass}" \
|
|||||||
fi
|
fi
|
||||||
printf "${ok}[%s] -- [SUCCESS] SQL databases dumped successfully --${norm}\n" \
|
printf "${ok}[%s] -- [SUCCESS] SQL databases dumped successfully --${norm}\n" \
|
||||||
"$(stamp)" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
|
# set cleanup flag
|
||||||
|
sqlCopied=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user