From 92519055fcd5ca0c71fbd83cdd659fe038632bd1 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Tue, 25 Sep 2018 18:01:29 -0600 Subject: [PATCH] Reformatted quit function log output --- cfddns.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cfddns.sh b/cfddns.sh index 801a48f..428f918 100755 --- a/cfddns.sh +++ b/cfddns.sh @@ -82,7 +82,8 @@ quit none function quit { if [ -z "$1" ]; then # exit cleanly - echo -e "\e[1;32m${stamp} -- Script completed --\e[0m" >> "$logFile" + echo -e "${bold}${note}${stamp} -- Script completed --\${normal}" \ + >> "$logFile" exit 0 elif [ "$1" = "none" ]; then if [ -z "$2" ]; then @@ -95,15 +96,14 @@ function quit { elif [ "$1" = "199" ]; then # list DNS entries that were not updated for failedName in "${failedDNS[@]}"; do - echo -e "\e[1;31m${stamp}" \ - "-- [ERROR] $failedName was NOT updated --\e[0m" >> "$logFile" + echo -e "${bold}${err}${stamp}" \ + "-- [ERROR] $failedName was NOT updated --${normal}" >> "$logFile" done exit "$1" else # notify use that error has occurred and provide exit code - echo -e "\e[1;31m${stamp}" \ - "-- [ERROR] Script exited with code $1 --" >> "$logFile" - echo -e "\e[0;31m${errorExplain[$1]}\e[0m" >> "$logFile" + echo -e "${bold}${err}${stamp}" \ + "-- [ERROR] ${errorExplain[$1]} (code: $1) --${normal}" >> "$logFile" exit "$1" fi } @@ -138,6 +138,7 @@ info="\e[96m" lit="\e[93m" note="\e[35m" + ## define error code explainations 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)."