refactor: change log tags
- separate tags for summary vs individual messages for accurate logwatch counting - update code 99 exit to match other errors - change CF error tags to match new format
This commit is contained in:
parent
fe0f9caef1
commit
220263c1f9
17
cfddns.sh
17
cfddns.sh
@ -63,13 +63,15 @@ exitError() {
|
|||||||
errMsg="Cloudflare zone id (cfZoneId) is either null or undefined. Please check your Cloudflare credentials file."
|
errMsg="Cloudflare zone id (cfZoneId) is either null or undefined. Please check your Cloudflare credentials file."
|
||||||
;;
|
;;
|
||||||
25)
|
25)
|
||||||
errMsg="Cloudflare API error. Please review any 'CF-ERROR' lines in this log for details."
|
errMsg="Cloudflare API error. Please review any 'CF-ERR:' lines in this log for details."
|
||||||
;;
|
;;
|
||||||
26)
|
26)
|
||||||
errMsg="${failedDomainCount} domain update(s) failed. Any 'CF-ERROR' lines noted in this log may help determine what went wrong."
|
errMsg="${failedDomainCount} domain update(s) failed. Any 'CF-ERR:' lines noted in this log may help determine what went wrong."
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%s[%s] ERROR: An unspecified error occurred. Exiting.%s\n" "$err" "$(stamp)" "$norm" >>"$logFile"
|
printf "%s[%s] ERR: Unknown error. (code: 99)%s\n" "$err" "$(stamp)" "$norm" >>"$logFile"
|
||||||
|
printf "%s[%s] ERROR: An unspecified error occurred.%s\n" "$err" "$(stamp)" "$norm" >>"$logFile"
|
||||||
|
printf "%s[%s] -- Cloudflare DDNS update-script: execution completed with error(s) --%s\n" "$err" "$(stamp)" "$norm" >>"$logFile"
|
||||||
exit 99
|
exit 99
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -99,7 +101,7 @@ listCFErrors() {
|
|||||||
messages="${messages#*_}"
|
messages="${messages#*_}"
|
||||||
|
|
||||||
# output to log
|
# output to log
|
||||||
printf "[%s] CF-ERROR: Code %s. %s\n" "$(stamp)" "$code" "$message"
|
printf "[%s] CF-ERR: Code %s. %s\n" "$(stamp)" "$code" "$message"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +207,6 @@ textblockSwitches() {
|
|||||||
printf "%s%s%s\n" "$cyan" "$1" "$norm"
|
printf "%s%s%s\n" "$cyan" "$1" "$norm"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### default variable values
|
### default variable values
|
||||||
scriptPath="$(CDPATH='' \cd -- "$(dirname -- "$0")" && pwd -P)"
|
scriptPath="$(CDPATH='' \cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||||
scriptName="$(basename "$0")"
|
scriptName="$(basename "$0")"
|
||||||
@ -439,7 +440,7 @@ while [ "$dnsRecordsToUpdate" != "${dnsRecordsToUpdate#*${dnsSeparator}}" ] && {
|
|||||||
if [ "$resultCount" = "0" ]; then
|
if [ "$resultCount" = "0" ]; then
|
||||||
# warn if record of host not found
|
# warn if record of host not found
|
||||||
printf "%sNOT FOUND%s\n" "$warn" "$norm" >>"$logFile"
|
printf "%sNOT FOUND%s\n" "$warn" "$norm" >>"$logFile"
|
||||||
printf "%s[%s] WARNING: Cannot find existing record to update for DNS entry: %s%s\n" "$warn" "$(stamp)" "$record" "$norm" >>"$logFile"
|
printf "%s[%s] WARN: Cannot find existing record to update for DNS entry: %s%s\n" "$warn" "$(stamp)" "$record" "$norm" >>"$logFile"
|
||||||
invalidDomainCount=$((invalidDomainCount + 1))
|
invalidDomainCount=$((invalidDomainCount + 1))
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -475,7 +476,7 @@ while [ "$dnsRecordsToUpdate" != "${dnsRecordsToUpdate#*${dnsSeparator}}" ] && {
|
|||||||
else
|
else
|
||||||
printf "%sFAILED%s\n" "$err" "$norm" >>"$logFile"
|
printf "%sFAILED%s\n" "$err" "$norm" >>"$logFile"
|
||||||
listCFErrors "$cfResult"
|
listCFErrors "$cfResult"
|
||||||
printf "%s[%s] ERROR: Unable to update IP address for %s%s\n" "$err" "$(stamp)" "$record" "$norm" >>"$logFile"
|
printf "%s[%s] ERR: Unable to update IP address for %s%s\n" "$err" "$(stamp)" "$record" "$norm" >>"$logFile"
|
||||||
# do not exit with error, API error here is probably an update issue specific to this host
|
# do not exit with error, API error here is probably an update issue specific to this host
|
||||||
# increment counter and note it after all processing finished
|
# increment counter and note it after all processing finished
|
||||||
failedDomainCount=$((failedDomainCount + 1))
|
failedDomainCount=$((failedDomainCount + 1))
|
||||||
@ -484,7 +485,7 @@ done
|
|||||||
|
|
||||||
# exit
|
# exit
|
||||||
if [ "$invalidDomainCount" -ne 0 ]; then
|
if [ "$invalidDomainCount" -ne 0 ]; then
|
||||||
printf "%s[%s] -- WARNING: %s invalid domain(s) were supplied for updating --%s\n" "$warn" "$(stamp)" "$invalidDomainCount" "$norm" >>"$logFile"
|
printf "%s[%s] WARNING: %s invalid domain(s) were supplied for updating%s\n" "$warn" "$(stamp)" "$invalidDomainCount" "$norm" >>"$logFile"
|
||||||
fi
|
fi
|
||||||
if [ "$failedDomainCount" -ne 0 ]; then
|
if [ "$failedDomainCount" -ne 0 ]; then
|
||||||
exitError 26
|
exitError 26
|
||||||
|
Loading…
Reference in New Issue
Block a user