Last active
April 13, 2020 15:38
-
-
Save ravage/9f671978efd8fa081c7acda074663201 to your computer and use it in GitHub Desktop.
asuswrt merlin cloudflare ddns update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# /jffs/scripts/ddns-start | |
zone=<zone_id> | |
record=<record_id> | |
token=<bearer_token> | |
fqdn=<fqdn> | |
myip=$(/usr/sbin/nvram get wan0_ipaddr) | |
payload=$(cat <<EOF | |
{ | |
"type":"A", | |
"name":"$fqdn", | |
"content":"$myip", | |
"ttl":1, | |
"proxied":false | |
} | |
EOF | |
) | |
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zone/dns_records/$record" \ | |
-H "Authorization: Bearer $token" \ | |
-H "Content-Type: application/json" \ | |
-d "$payload" \ | |
-s -f > /dev/null | |
if [ $? -eq 0 ]; then | |
/sbin/ddns_custom_updated 1 | |
else | |
/sbin/ddns_custom_updated 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment