Compare commits
34 Commits
2.2
...
92e69d1b85
| Author | SHA1 | Date | |
|---|---|---|---|
| 92e69d1b85 | |||
| 00ea88780d | |||
| d9aa8973a3 | |||
| ec75cffbf1 | |||
| b8fb744623 | |||
| d0b2c781bf | |||
| c4d28d1f8c | |||
| f085838781 | |||
| 4a6c339a07 | |||
| c94f12e976 | |||
| 5443612381 | |||
| df144a5211 | |||
| 04811805c3 | |||
| aa446c00e6 | |||
| 56a5ad59fe | |||
| ce1ab86d22 | |||
| cae57ccf6b | |||
| 0fcd0d9c13 | |||
| e411a35b93 | |||
| 0e787be456 | |||
| 17c33d237f | |||
| 5b55ac95a3 | |||
| f4dc8f44b1 | |||
| 3792881529 | |||
| c1f54a619c | |||
| 4c997a6b7d | |||
| 1824d9f139 | |||
| 50b4cf105f | |||
| 1e3b545a23 | |||
| 380509c966 | |||
| 71da487aa8 | |||
| 3be6eaee0c | |||
| 5c6c8ec4ea | |||
| c7297a512c |
@@ -55,6 +55,23 @@
|
|||||||
*.bat text eol=crlf
|
*.bat text eol=crlf
|
||||||
*.cmd text eol=crlf
|
*.cmd text eol=crlf
|
||||||
|
|
||||||
|
# web frontend stack -- force LF so SRI hashes are always correct
|
||||||
|
*.html text eol=lf
|
||||||
|
*.htm text eol=lf
|
||||||
|
*.css text eol=lf
|
||||||
|
*.min.css text eol=lf
|
||||||
|
*.js text eol=lf
|
||||||
|
*.min.js text eol=lf
|
||||||
|
*.php text eol=lf
|
||||||
|
|
||||||
|
# Visual Studio projects (Rider also)
|
||||||
|
*.cs diff=csharp
|
||||||
|
*.sln merge=union
|
||||||
|
*.csproj merge=union
|
||||||
|
*.vbproj merge=union
|
||||||
|
*.fsproj merge=union
|
||||||
|
*.dbproj merge=union
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
*.json text
|
*.json text
|
||||||
*.toml text
|
*.toml text
|
||||||
@@ -79,3 +96,5 @@
|
|||||||
.gitattributes export-ignore
|
.gitattributes export-ignore
|
||||||
.gitignore export-ignore
|
.gitignore export-ignore
|
||||||
.gitkeep export-ignore
|
.gitkeep export-ignore
|
||||||
|
.idea export-ignore
|
||||||
|
.vscode export-ignore
|
||||||
|
|||||||
+34
@@ -1 +1,35 @@
|
|||||||
|
#
|
||||||
|
# JetBrains exclusions
|
||||||
|
#
|
||||||
|
|
||||||
|
riderModule.iml
|
||||||
|
/_ReSharper.Caches/
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
.idea/**/GitCommitMessageStorage.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# modules
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# project-specific exclusions
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DeveloperToolsToolWindowSettingsV1" lastSelectedContentNodeId="base64-encoder-decoder" pluginVersion="9.0.0">
|
||||||
|
<developerToolsConfigurations />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+15
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GitToolBoxProjectSettings">
|
||||||
|
<option name="commitMessageIssueKeyValidationOverride">
|
||||||
|
<BoolValueOverride>
|
||||||
|
<option name="enabled" value="true" />
|
||||||
|
</BoolValueOverride>
|
||||||
|
</option>
|
||||||
|
<option name="commitMessageValidationEnabledOverride">
|
||||||
|
<BoolValueOverride>
|
||||||
|
<option name="enabled" value="true" />
|
||||||
|
</BoolValueOverride>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="com.itcodebox.notebooks.projectservice.ProjectUIState">
|
||||||
|
<option name="selectedNotebookId" value="1" />
|
||||||
|
<option name="selectedChapterId" value="1" />
|
||||||
|
<option name="selectedNoteId" value="1" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RiderProjectSettingsUpdater">
|
||||||
|
<option name="singleClickDiffPreview" value="1" />
|
||||||
|
<option name="unhandledExceptionsIgnoreList" value="1" />
|
||||||
|
<option name="vcsConfiguration" value="3" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
#
|
#
|
||||||
# update Cloudflare DNS records with current (dynamic) IP address
|
# update Cloudflare DNS records with current (dynamic) IP address
|
||||||
# Script by Asif Bacchus <asif@bacchus.cloud>
|
# Script by Asif Bacchus <asif@bacchus.cloud>
|
||||||
# Last modified: May 10, 2021
|
# Last modified: July 19, 2026
|
||||||
# Version 2.2
|
# Version 3.0
|
||||||
#
|
#
|
||||||
|
|
||||||
### text formatting presets using tput
|
### text formatting presets using tput
|
||||||
@@ -157,6 +157,10 @@ scriptHelp() {
|
|||||||
textBlock "Switch value. Output log to console (stdout) instead of a log file. Can be combined with --nc if desired."
|
textBlock "Switch value. Output log to console (stdout) instead of a log file. Can be combined with --nc if desired."
|
||||||
textBlockDefaults "(disabled: output to log file)"
|
textBlockDefaults "(disabled: output to log file)"
|
||||||
newline
|
newline
|
||||||
|
textBlockSwitches "--log-journal"
|
||||||
|
textBlock "Switch value. Output a structured log entry to your journaling system instead of a log file. Implies --nc."
|
||||||
|
textBlockDefaults "(disabled: output to log file)"
|
||||||
|
newline
|
||||||
textBlockSwitches "--no-log"
|
textBlockSwitches "--no-log"
|
||||||
textBlock "Switch value. Do not create a log (i.e. no console, no file). You will not have *any* output from the script if you choose this option, so you will not know if updates succeeded or failed."
|
textBlock "Switch value. Do not create a log (i.e. no console, no file). You will not have *any* output from the script if you choose this option, so you will not know if updates succeeded or failed."
|
||||||
textBlockDefaults "(disabled: output to log file)"
|
textBlockDefaults "(disabled: output to log file)"
|
||||||
@@ -253,6 +257,7 @@ writeLog() {
|
|||||||
scriptPath="$(CDPATH='' \cd -- "$(dirname -- "$0")" && pwd -P)"
|
scriptPath="$(CDPATH='' \cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||||
scriptName="$(basename "$0")"
|
scriptName="$(basename "$0")"
|
||||||
logFile="$scriptPath/${scriptName%.*}.log"
|
logFile="$scriptPath/${scriptName%.*}.log"
|
||||||
|
logToJournal=0
|
||||||
accountFile="$scriptPath/cloudflare.credentials"
|
accountFile="$scriptPath/cloudflare.credentials"
|
||||||
colourizeLogFile=1
|
colourizeLogFile=1
|
||||||
dnsRecords=""
|
dnsRecords=""
|
||||||
@@ -292,6 +297,10 @@ while [ $# -gt 0 ]; do
|
|||||||
# log to the console instead of a file
|
# log to the console instead of a file
|
||||||
logFile="/dev/stdout"
|
logFile="/dev/stdout"
|
||||||
;;
|
;;
|
||||||
|
--log-journal)
|
||||||
|
# log to the journal system instead of a file
|
||||||
|
logToJournal=1
|
||||||
|
;;
|
||||||
--no-log)
|
--no-log)
|
||||||
# do not log anything
|
# do not log anything
|
||||||
logFile="/dev/null"
|
logFile="/dev/null"
|
||||||
@@ -364,6 +373,10 @@ fi
|
|||||||
if [ ! -f "$accountFile" ] || [ ! -s "$accountFile" ]; then
|
if [ ! -f "$accountFile" ] || [ ! -s "$accountFile" ]; then
|
||||||
badParam errMsg "Cannot find Cloudflare credentials file (${accountFile}). Exiting."
|
badParam errMsg "Cannot find Cloudflare credentials file (${accountFile}). Exiting."
|
||||||
fi
|
fi
|
||||||
|
if ! 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"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
# turn off log file colourization if parameter is set
|
# turn off log file colourization if parameter is set
|
||||||
if [ "$colourizeLogFile" -eq 0 ]; then
|
if [ "$colourizeLogFile" -eq 0 ]; then
|
||||||
bold=""
|
bold=""
|
||||||
@@ -378,6 +391,7 @@ fi
|
|||||||
|
|
||||||
### initial log entries
|
### initial log entries
|
||||||
{
|
{
|
||||||
|
|
||||||
printf "%s[%s] -- Cloudflare DDNS update-script: starting --%s\n" "$ok" "$(stamp)" "$norm"
|
printf "%s[%s] -- Cloudflare DDNS update-script: starting --%s\n" "$ok" "$(stamp)" "$norm"
|
||||||
printf "Parameters:\n"
|
printf "Parameters:\n"
|
||||||
printf "script path: %s\n" "$scriptPath/$scriptName"
|
printf "script path: %s\n" "$scriptPath/$scriptName"
|
||||||
@@ -415,7 +429,9 @@ fi
|
|||||||
record="${dnsRecordsToUpdate%%${dnsSeparator}*}"
|
record="${dnsRecordsToUpdate%%${dnsSeparator}*}"
|
||||||
dnsRecordsToUpdate="${dnsRecordsToUpdate#*${dnsSeparator}}"
|
dnsRecordsToUpdate="${dnsRecordsToUpdate#*${dnsSeparator}}"
|
||||||
|
|
||||||
if [ -z "$record" ]; then continue; fi
|
if [ -z "$record" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
printf "updating record: %s\n" "$record"
|
printf "updating record: %s\n" "$record"
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -426,13 +442,13 @@ fi
|
|||||||
writeLog process "Reading Cloudflare credentials"
|
writeLog process "Reading Cloudflare credentials"
|
||||||
case "$accountFile" in
|
case "$accountFile" in
|
||||||
/*)
|
/*)
|
||||||
# absolute path, use as-is
|
# absolute path, use as-is
|
||||||
# shellcheck source=./cloudflare.credentials
|
# shellcheck source=./cloudflare.credentials
|
||||||
. "$accountFile"
|
. "$accountFile"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# relative path, rewrite
|
# relative path, rewrite
|
||||||
# shellcheck source=./cloudflare.credentials
|
# shellcheck source=./cloudflare.credentials
|
||||||
. "./$accountFile"
|
. "./$accountFile"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -459,13 +475,17 @@ while [ -n "$dnsRecordsToUpdate" ] && [ "$dnsRecordsToUpdate" != "$dnsSeparator"
|
|||||||
record="${dnsRecordsToUpdate%%${dnsSeparator}*}"
|
record="${dnsRecordsToUpdate%%${dnsSeparator}*}"
|
||||||
dnsRecordsToUpdate="${dnsRecordsToUpdate#*${dnsSeparator}}"
|
dnsRecordsToUpdate="${dnsRecordsToUpdate#*${dnsSeparator}}"
|
||||||
|
|
||||||
if [ -z "$record" ]; then continue; fi
|
if [ -z "$record" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
writeLog process "Processing ${record}"
|
writeLog process "Processing ${record}"
|
||||||
|
|
||||||
# exit if curl/network error
|
# exit if curl/network error
|
||||||
if ! cfLookup="$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${cfZoneId}/dns_records?name=${record}&type=${recordType}" \
|
if ! cfLookup="$(
|
||||||
|
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${cfZoneId}/dns_records?name=${record}&type=${recordType}" \
|
||||||
-H "Authorization: Bearer ${cfKey}" \
|
-H "Authorization: Bearer ${cfKey}" \
|
||||||
-H "Content-Type: application/json")"; then
|
-H "Content-Type: application/json"
|
||||||
|
)"; then
|
||||||
writeLog process-error
|
writeLog process-error
|
||||||
exitError 3
|
exitError 3
|
||||||
fi
|
fi
|
||||||
@@ -506,10 +526,12 @@ while [ -n "$dnsRecordsToUpdate" ] && [ "$dnsRecordsToUpdate" != "$dnsSeparator"
|
|||||||
updateJSON="$(jq -n --arg key0 content --arg value0 "${ipAddress}" '{($key0):$value0}')"
|
updateJSON="$(jq -n --arg key0 content --arg value0 "${ipAddress}" '{($key0):$value0}')"
|
||||||
|
|
||||||
# exit if curl/network error
|
# exit if curl/network error
|
||||||
if ! cfResult="$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/${cfZoneId}/dns_records/${objectId}" \
|
if ! cfResult="$(
|
||||||
|
curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/${cfZoneId}/dns_records/${objectId}" \
|
||||||
-H "Authorization: Bearer ${cfKey}" \
|
-H "Authorization: Bearer ${cfKey}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "${updateJSON}")"; then
|
--data "${updateJSON}"
|
||||||
|
)"; then
|
||||||
writeLog process-error
|
writeLog process-error
|
||||||
exitError 3
|
exitError 3
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
getTimeStamp() {
|
||||||
|
(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
}
|
||||||
|
|
||||||
|
getHostname() {
|
||||||
|
(hostname -s)
|
||||||
|
}
|
||||||
|
|
||||||
|
lowercase() {
|
||||||
|
echo "$1" | tr '[:upper:]' '[:lower:]'
|
||||||
|
}
|
||||||
|
|
||||||
|
uppercase() {
|
||||||
|
echo "$1" | tr '[:lower:]' '[:upper:]'
|
||||||
|
}
|
||||||
|
|
||||||
|
standardizeLogLevels() {
|
||||||
|
LEVEL_TO_STANDARDIZE="$(lowercase "$1")"
|
||||||
|
case "$LEVEL_TO_STANDARDIZE" in
|
||||||
|
"critical" | "crit" | "fatal")
|
||||||
|
echo "CRIT"
|
||||||
|
;;
|
||||||
|
"error" | "err")
|
||||||
|
echo "ERR"
|
||||||
|
;;
|
||||||
|
"warning" | "warn")
|
||||||
|
echo "WARN"
|
||||||
|
;;
|
||||||
|
"information" | "info")
|
||||||
|
echo "INFO"
|
||||||
|
;;
|
||||||
|
"debug" | "verbose")
|
||||||
|
echo "DEBUG"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "INFO"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
translateLogLevelsToJournalD() {
|
||||||
|
LEVEL_TO_TRANSLATE="$(standardizeLogLevels "$1")"
|
||||||
|
case "$LEVEL_TO_TRANSLATE" in
|
||||||
|
"CRIT")
|
||||||
|
echo 2
|
||||||
|
;;
|
||||||
|
"ERR")
|
||||||
|
echo 3
|
||||||
|
;;
|
||||||
|
"WARN")
|
||||||
|
echo 4
|
||||||
|
;;
|
||||||
|
"INFO")
|
||||||
|
echo 6
|
||||||
|
;;
|
||||||
|
"DEBUG")
|
||||||
|
echo 7
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 6
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# modified syslog fmt: <ISO-8601 timestamp> <hostname> <tag>[pid]: [LEVEL:$2] [STATUS:$3] <MESSAGE:$1> (<OPERATION:$4>:<CODE:$5>)
|
||||||
|
writePlainTextLog() {
|
||||||
|
# not enough information to generate a meaningful log message
|
||||||
|
if [ -z "$1" ] || [ $# -lt 3 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "%s %s %s[%s]: [%s] [%s] %s (%s:%s)\n" \
|
||||||
|
"$(getTimeStamp)" "$(getHostname)" "$LOG_PROGRAM_NAME" "$$" \
|
||||||
|
"$(standardizeLogLevels "$2")" "$(uppercase "$3")" "$1" "${4:-UNSPECIFIED}" "${5:-999}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: message, $2: level, $3: status, [$4: operation], [$5: code]
|
||||||
|
writeJsonLog() {
|
||||||
|
# not enough information to generate a meaningful log message
|
||||||
|
if [ -z "$1" ] || [ $# -lt 3 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROPS="$(
|
||||||
|
jq --null-input \
|
||||||
|
--arg timestamp "$(getTimeStamp)" \
|
||||||
|
--arg hostname "$(getHostname)" \
|
||||||
|
--arg pName "$LOG_PROGRAM_NAME" \
|
||||||
|
--arg pid "$$" \
|
||||||
|
--arg level "$(standardizeLogLevels "$2")" \
|
||||||
|
--arg status "$(uppercase "$3")" \
|
||||||
|
--arg message "$1" \
|
||||||
|
--arg operation "${4:-UNSPECIFIED}" \
|
||||||
|
--arg code "${5:-999}" \
|
||||||
|
'{"timestamp":$timestamp, "hostname":$hostname, "programName":$pName, "pid":$pid, "level":$level, "status":$status, "message":$message, "operation":$operation, "code":$code}' \
|
||||||
|
)"
|
||||||
|
|
||||||
|
echo "$PROPS" | jq "."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1: message, $2: level, $3: status, $4: operation, $5: code
|
||||||
|
writeJournalDLog() {
|
||||||
|
# not enough information to generate a meaningful log message
|
||||||
|
if [ -z "$1" ] || [ $# -lt 3 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
J_TIMESTAMP="$(getTimeStamp)"
|
||||||
|
J_PID="$$"
|
||||||
|
J_PRIO="$(translateLogLevelsToJournalD "$2")"
|
||||||
|
J_STAT="$(uppercase "$3")"
|
||||||
|
|
||||||
|
logger --journald <<end
|
||||||
|
SYSLOG_TIMESTAMP=${J_TIMESTAMP}
|
||||||
|
SYSLOG_FACILITY=3
|
||||||
|
SYSLOG_IDENTIFIER=${LOG_PROGRAM_NAME}
|
||||||
|
SYSLOG_PID=${J_PID}
|
||||||
|
PRIORITY=${J_PRIO}
|
||||||
|
STATUS=${J_STAT}
|
||||||
|
MESSAGE=$1
|
||||||
|
OPERATION=${4:-UNSPECIFIED}
|
||||||
|
ERRNO=${5:-999}
|
||||||
|
end
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_PROGRAM_NAME="cfddns"
|
||||||
|
|
||||||
|
if [ "$1" = "text" ]; then
|
||||||
|
writePlainTextLog # this will do nothing
|
||||||
|
writePlainTextLog "Testing plain-text logging output" # this will also do nothing
|
||||||
|
writePlainTextLog "Informational plain-text log message" "information" "ok" # info message
|
||||||
|
writePlainTextLog "Plain-text message forced to info level" "whoops" "ok" # level translated to default
|
||||||
|
writePlainTextLog "Warning! This is plain-text." "warning" "flagged" # warning level with 'flagged' status
|
||||||
|
writePlainTextLog "Error sample! This is plain-text." "err" "error" # error level message
|
||||||
|
writePlainTextLog "Unable to continue, critical failure. (This is plain-text)" "fatal" "exit" "startup" "2" # critical level error with operation and error code
|
||||||
|
elif [ "$1" = "json" ]; then
|
||||||
|
writeJsonLog # this will do nothing
|
||||||
|
writeJsonLog "This is a test message" # this will also do nothing
|
||||||
|
writeJsonLog "Informational JSON log message" "information" "ok" # info message
|
||||||
|
writeJsonLog "JSON message forced to info level" "whoops" "ok" # level translated to default
|
||||||
|
writeJsonLog "Warning! This is JSON." "warning" "flagged" # warning level with 'flagged' status
|
||||||
|
writeJsonLog "Error sample! This is JSON." "err" "error" # error level message
|
||||||
|
writeJsonLog "Unable to continue, critical failure. (This is JSON)" "fatal" "exit" "startup" "2" # critical level error with operation and error code
|
||||||
|
elif [ "$1" = "journal" ]; then
|
||||||
|
writeJournalDLog # this will do nothing
|
||||||
|
writeJournalDLog "This is a test message" # this will also do nothing
|
||||||
|
writeJournalDLog "Informational JOURNALD log message" "information" "ok" # info message
|
||||||
|
writeJournalDLog "JOURNALD message forced to info level" "whoops" "ok" # level translated to default
|
||||||
|
writeJournalDLog "Warning! This is a JOURNALD message." "warning" "flagged" # warning level with 'flagged' status
|
||||||
|
writeJournalDLog "Error sample! This is a JOURNALD." "err" "error" # error level message
|
||||||
|
writeJournalDLog "Unable to continue, critical failure. (This is JOURNALD message)" "fatal" "exit" "startup" "2" # critical level error with operation and error code
|
||||||
|
else
|
||||||
|
printf "\nPlease specify either 'text', 'json', or 'journal' after the script name. Exiting.\n\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user