1
0
mirror of https://github.com/kremalicious/dotfiles.git synced 2024-12-22 01:03:24 +01:00

add cloudflare dyndns script

This commit is contained in:
Matthias Kretschmann 2021-02-16 20:24:14 +01:00
parent 67609ed7a6
commit e7f2792160
Signed by: m
GPG Key ID: 606EEEF3C479A91F

22
bin/cloudflare-dyndns.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Required env vars
# CLOUDFLARE_ZONE="xxx"
# CLOUDFLARE_DNS_RECORD_ID="xxx"
# CLOUDFLARE_EMAIL="xxx"
# CLOUDFLARE_KEY="xxx"
# Update Cloudflare DNS record with current detected public IP
# https://api.cloudflare.com/#dns-records-for-a-zone-patch-dns-record
function updateIp {
IPADDR=$(curl -s checkip.amazonaws.com)
echo $IPADDR
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/dns_records/$CLOUDFLARE_DNS_RECORD_ID" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_KEY" \
-H "Content-Type: application/json" \
--data "{\"content\":\"$IPADDR\"}"
}
updateIp