Reformatted quit function log output

This commit is contained in:
Asif Bacchus 2018-09-25 18:01:29 -06:00
parent 3585490f80
commit 92519055fc

View File

@ -82,7 +82,8 @@ quit none
function quit { function quit {
if [ -z "$1" ]; then if [ -z "$1" ]; then
# exit cleanly # exit cleanly
echo -e "\e[1;32m${stamp} -- Script completed --\e[0m" >> "$logFile" echo -e "${bold}${note}${stamp} -- Script completed --\${normal}" \
>> "$logFile"
exit 0 exit 0
elif [ "$1" = "none" ]; then elif [ "$1" = "none" ]; then
if [ -z "$2" ]; then if [ -z "$2" ]; then
@ -95,15 +96,14 @@ function quit {
elif [ "$1" = "199" ]; then elif [ "$1" = "199" ]; then
# list DNS entries that were not updated # list DNS entries that were not updated
for failedName in "${failedDNS[@]}"; do for failedName in "${failedDNS[@]}"; do
echo -e "\e[1;31m${stamp}" \ echo -e "${bold}${err}${stamp}" \
"-- [ERROR] $failedName was NOT updated --\e[0m" >> "$logFile" "-- [ERROR] $failedName was NOT updated --${normal}" >> "$logFile"
done done
exit "$1" exit "$1"
else else
# notify use that error has occurred and provide exit code # notify use that error has occurred and provide exit code
echo -e "\e[1;31m${stamp}" \ echo -e "${bold}${err}${stamp}" \
"-- [ERROR] Script exited with code $1 --" >> "$logFile" "-- [ERROR] ${errorExplain[$1]} (code: $1) --${normal}" >> "$logFile"
echo -e "\e[0;31m${errorExplain[$1]}\e[0m" >> "$logFile"
exit "$1" exit "$1"
fi fi
} }
@ -138,6 +138,7 @@ info="\e[96m"
lit="\e[93m" lit="\e[93m"
note="\e[35m" note="\e[35m"
## define error code explainations ## define error code explainations
errorExplain[1]="Missing or invalid parameters on script invocation." errorExplain[1]="Missing or invalid parameters on script invocation."
errorExplain[2]="curl is required to access CloudFlare API. Please install curl. (apt-get install curl on debian/ubuntu)." errorExplain[2]="curl is required to access CloudFlare API. Please install curl. (apt-get install curl on debian/ubuntu)."