Created
November 13, 2015 09:51
-
-
Save stormf/b93de56e2f9f7497a4c2 to your computer and use it in GitHub Desktop.
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 | |
. /etc/update-cloudflare/config | |
WAN_IP=`curl http://icanhazip.com/ 2> /dev/null` | |
OLD_WAN_IP=`cat $tmpfile` | |
if [ "$WAN_IP" = "$OLD_WAN_IP" ] | |
then | |
touch $tmpfile | |
else | |
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records/$record_id" \ | |
-H "Content-Type:application/json" \ | |
-H "X-Auth-Key:$cf_auth_key" \ | |
-H "X-Auth-Email:$cf_email" \ | |
--data '{ | |
"id":"'"$record_id"'", | |
"type":"A", | |
"name":"'"$fqdn"'", | |
"content":"'"$WAN_IP"'", | |
"ttl":"'"$ttl"'", | |
"zone_id":"'"$zone_id"'", | |
"zone_name":"'"$zone_name"'", | |
"data":{} | |
}' | |
echo $WAN_IP > $tmpfile | |
fi |
Author
stormf
commented
Nov 13, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment