mirror of
https://codeberg.org/polyteknisk-radiogruppe/the_prg_server_configuration.git
synced 2026-06-13 18:28:55 +02:00
Fix Cloudflare API token handling
This commit is contained in:
parent
c8c1e0ec22
commit
1f3594efa5
1 changed files with 4 additions and 4 deletions
|
|
@ -613,7 +613,7 @@ in {
|
||||||
source "${envFile}"
|
source "${envFile}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
|
if [ -z "$${CLOUDFLARE_API_TOKEN:-}" ]; then
|
||||||
echo "CLOUDFLARE_API_TOKEN is not set in ${envFile}, aborting" >&2
|
echo "CLOUDFLARE_API_TOKEN is not set in ${envFile}, aborting" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
@ -633,7 +633,7 @@ in {
|
||||||
local fqdn="$1"
|
local fqdn="$1"
|
||||||
# Query existing A records for fqdn
|
# Query existing A records for fqdn
|
||||||
res=$(curl -sS -X GET "$API_BASE/zones/${zoneId}/dns_records?type=A&name=$fqdn" \
|
res=$(curl -sS -X GET "$API_BASE/zones/${zoneId}/dns_records?type=A&name=$fqdn" \
|
||||||
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
-H "Authorization: Bearer $${CLOUDFLARE_API_TOKEN:-}" \
|
||||||
-H "Content-Type: application/json")
|
-H "Content-Type: application/json")
|
||||||
|
|
||||||
ok=$(echo "$res" | $jq -r '.success')
|
ok=$(echo "$res" | $jq -r '.success')
|
||||||
|
|
@ -658,13 +658,13 @@ in {
|
||||||
if [ -n "$record_id" ]; then
|
if [ -n "$record_id" ]; then
|
||||||
echo "Updating $fqdn ($record_id) -> $CURRENT_IP"
|
echo "Updating $fqdn ($record_id) -> $CURRENT_IP"
|
||||||
curl -sS -X PUT "$API_BASE/zones/${zoneId}/dns_records/$record_id" \
|
curl -sS -X PUT "$API_BASE/zones/${zoneId}/dns_records/$record_id" \
|
||||||
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
-H "Authorization: Bearer $${CLOUDFLARE_API_TOKEN:-}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "$payload" | $jq -r '.'
|
--data "$payload" | $jq -r '.'
|
||||||
else
|
else
|
||||||
echo "Creating record $fqdn -> $CURRENT_IP"
|
echo "Creating record $fqdn -> $CURRENT_IP"
|
||||||
curl -sS -X POST "$API_BASE/zones/${zoneId}/dns_records" \
|
curl -sS -X POST "$API_BASE/zones/${zoneId}/dns_records" \
|
||||||
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
-H "Authorization: Bearer $${CLOUDFLARE_API_TOKEN:-}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "$payload" | $jq -r '.'
|
--data "$payload" | $jq -r '.'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue