style(fmt): Reformat shell script
This commit is contained in:
@@ -391,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"
|
||||||
@@ -428,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
|
||||||
|
|
||||||
@@ -439,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
|
||||||
@@ -472,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
|
||||||
@@ -519,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
|
||||||
|
|||||||
Reference in New Issue
Block a user