mirror of
https://github.com/kremalicious/dotfiles.git
synced 2024-11-22 01:37:14 +01:00
add cloudflare dyndns script
This commit is contained in:
parent
67609ed7a6
commit
e7f2792160
22
bin/cloudflare-dyndns.sh
Executable file
22
bin/cloudflare-dyndns.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user