feat(params): Use badparam func to manage logging
This commit is contained in:
@@ -47,7 +47,7 @@ badParam() {
|
|||||||
elif [ "$1" = "errMsg" ]; then
|
elif [ "$1" = "errMsg" ]; then
|
||||||
printf "\n%sERROR: %s%s\n\n" "$err" "$2" "$norm"
|
printf "\n%sERROR: %s%s\n\n" "$err" "$2" "$norm"
|
||||||
([ "$logToConsole" -eq 0 ]) && writePlainTextLog \
|
([ "$logToConsole" -eq 0 ]) && writePlainTextLog \
|
||||||
"$2" "critical" "fail" "preexec" 1
|
"${2%%\Exit*}" "fatal" "fail" "preexec" 1
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -376,14 +376,10 @@ if ! command -v jq >/dev/null; then
|
|||||||
fi
|
fi
|
||||||
if [ -z "$dnsRecords" ]; then
|
if [ -z "$dnsRecords" ]; then
|
||||||
badParam errMsg "You must specify at least one DNS record to update. Exiting."
|
badParam errMsg "You must specify at least one DNS record to update. Exiting."
|
||||||
([ "$logToConsole" -eq 0 ]) &&
|
|
||||||
writePlainTextLog "At least one DNS record to update must be specified" "fatal" "fail" "params" 1
|
|
||||||
fi
|
fi
|
||||||
# verify the credentials file exists and is not empty (default check)
|
# verify the credentials file exists and is not empty (default check)
|
||||||
if [ ! -f "$accountFile" ] || [ ! -s "$accountFile" ]; then
|
if [ ! -f "$accountFile" ] || [ ! -s "$accountFile" ]; then
|
||||||
badParam errMsg "Cannot find the Cloudflare credentials file (${accountFile}). Exiting."
|
badParam errMsg "Cannot find the Cloudflare credentials file (${accountFile}) or it is empty. Exiting."
|
||||||
([ "$logToConsole" -eq 0 ]) &&
|
|
||||||
writePlainTextLog "Cannot find the specified Cloudflare credentials file (${accountFile})" "fatal" "fail" "params" 1
|
|
||||||
fi
|
fi
|
||||||
if [ "$logToJournal" -eq 1 ] && ! command -v logger >/dev/null 2>&1; then
|
if [ "$logToJournal" -eq 1 ] && ! command -v logger >/dev/null 2>&1; then
|
||||||
printf "\n%sThis script requires 'logger' be installed to write entries to your journaling system. Exiting.%s\n\n" "$err" "$norm"
|
printf "\n%sThis script requires 'logger' be installed to write entries to your journaling system. Exiting.%s\n\n" "$err" "$norm"
|
||||||
|
|||||||
Reference in New Issue
Block a user