funcs cleanup, exitError: printf formatting

This commit is contained in:
Asif Bacchus 2020-08-14 00:00:09 -06:00
parent ffc7579666
commit e74971997f
1 changed files with 14 additions and 14 deletions

View File

@ -74,39 +74,39 @@ 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 "%s[%s] -- [WARNING] Could not remove 503 error page." \
"$warn" "$(stamp)" >> "$logFile"
printf " Web interface will not function until this file is " \
>> "$logFile"
printf "removed --${norm}\n" >> "$logFile"
printf "removed --%s\n" "$norm" >> "$logFile"
warnCount=$((warnCount+1))
else
printf "${cyan}[%s] -- [INFO] 503 error page removed --${norm}\n" \
"$(stamp)" >> "$logFile"
printf "%s[%s] -- [INFO] 503 error page removed --%s\n" \
"$cyan" "$(stamp)" "$norm" >> "$logFile"
fi
fi
# remove EML temporary directory
if ! rm -rf "$exportDir" 2>>"$logFile"; then
printf "${warn}[%s] -- [WARNING] Could not remove EML export tmp dir:" \
"$(stamp)" >> "$logFile"
printf "%s[%s] -- [WARNING] Could not remove EML export tmp dir:" \
"$warn" "$(stamp)" >> "$logFile"
printf "\n%s\n" "$exportDir" >> "$logFile"
printf "please remove this directory manually! --${norm}\n" \
printf "please remove this directory manually! --%s\n" "$norm" \
>> "$logFile"
warnCount=$((warnCount+1))
else
printf "${cyan}[%s] -- [INFO] EML temp directory removed --${norm}\n" \
"$(stamp)" >> "$logFile"
printf "%s[%s] -- [INFO] EML temp directory removed --%s\n" \
"$cyan" "$(stamp)" "$norm" >> "$logFile"
fi
}
# call cleanup and then exit with error report
exitError () {
printf "${err}[%s] -- [ERROR] %s: %s --${norm}\n" \
"$(stamp)" "$1" "$2" >> "$logFile"
printf "%s[%s] -- [ERROR] %s: %s --%s\n" \
"$err" "$(stamp)" "$1" "$2" "$norm" >> "$logFile"
cleanup
# note script completion with error
printf "${err}[%s] --- %s execution completed with error ---${norm}\n" \
"$(stamp)" "$scriptName" >> "$logFile"
printf "%s[%s] --- %s execution completed with error ---%s\n" \
"$err" "$(stamp)" "$scriptName" "$norm" >> "$logFile"
exit "$1"
}