fix(params): Fix pre-flight console log dedup
This commit is contained in:
@@ -239,6 +239,7 @@ scriptPath="$(CDPATH='' \cd -- "$(dirname -- "$0")" && pwd -P)"
|
|||||||
scriptName="$(basename "$0")"
|
scriptName="$(basename "$0")"
|
||||||
logFile="$scriptPath/${scriptName%.*}.log"
|
logFile="$scriptPath/${scriptName%.*}.log"
|
||||||
logToJournal=0
|
logToJournal=0
|
||||||
|
logToConsole=0
|
||||||
logDebug=0
|
logDebug=0
|
||||||
useJsonLogFmt=1
|
useJsonLogFmt=1
|
||||||
useSyslogLogFmt=0
|
useSyslogLogFmt=0
|
||||||
@@ -280,6 +281,7 @@ while [ $# -gt 0 ]; do
|
|||||||
--log-console)
|
--log-console)
|
||||||
# use console-based logging
|
# use console-based logging
|
||||||
logFile="/dev/stdout"
|
logFile="/dev/stdout"
|
||||||
|
logToConsole=1
|
||||||
;;
|
;;
|
||||||
--log-journal)
|
--log-journal)
|
||||||
# use journald-based logging
|
# use journald-based logging
|
||||||
@@ -355,24 +357,24 @@ done
|
|||||||
|
|
||||||
### pre-flight checks
|
### pre-flight checks
|
||||||
if ! command -v curl >/dev/null; then
|
if ! command -v curl >/dev/null; then
|
||||||
printf "\n%sThis script requires 'curl' be installed and accessible. Exiting.%s\n\n" "$err" "$norm"
|
printf "\n%sThis script requires that 'curl' is installed and accessible. Exiting.%s\n\n" "$err" "$norm"
|
||||||
[ "$logToConsole" -eq 0 ] && writePlainTextLog "'curl' must be installed and accessible" "fatal" "fail" "preexec" 2
|
([ "$logToConsole" -eq 0 ]) && writePlainTextLog "'curl' must be installed and accessible" "fatal" "fail" "preexec" 2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
if ! command -v jq >/dev/null; then
|
if ! command -v jq >/dev/null; then
|
||||||
printf "\n%sThis script requires 'jq' be installed and accessible. Exiting.%s\n\n" "$err" "$norm"
|
printf "\n%sThis script requires that 'jq' is installed and accessible. Exiting.%s\n\n" "$err" "$norm"
|
||||||
[ "$logToConsole" -eq 0 ] && writePlainTextLog "'jq' must be installed and accessible" "fatal" "fail" "preexec" 2
|
([ "$logToConsole" -eq 0 ]) && writePlainTextLog "'jq' must be installed and accessible" "fatal" "fail" "preexec" 2
|
||||||
exit 2
|
exit 2
|
||||||
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 ] &&
|
([ "$logToConsole" -eq 0 ]) &&
|
||||||
writePlainTextLog "At least one DNS record to update must be specified" "fatal" "fail" "params" 1
|
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}). Exiting."
|
||||||
[ "$logToConsole" -eq 0 ] &&
|
([ "$logToConsole" -eq 0 ]) &&
|
||||||
writePlainTextLog "Cannot find the specified Cloudflare credentials file (${accountFile})" "fatal" "fail" "params" 1
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user