Last active
December 19, 2019 06:37
-
-
Save pacmac/230f8db646463b26d8b56b72b75ac620 to your computer and use it in GitHub Desktop.
linode update dns with APIV4
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 | |
TOKEN="" | |
DOMAIN_ID="" | |
RECORD_ID="" | |
WAN_IP=`curl -s ipecho.net/plain`; | |
OLD_WAN_IP=`cat /tmp/CURRENT_WAN_IP.txt` | |
func_go () { | |
curl -H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $TOKEN" \ | |
-X PUT -d "{ | |
\"name\": \"$SUB_NAME\", | |
\"target\": \"$WAN_IP\" | |
}" \ | |
"https://api.linode.com/v4/domains/$DOMAIN_ID/records/$RECORD_ID" | |
} | |
if [ "$WAN_IP" = "$OLD_WAN_IP" ]; then | |
echo "IP Unchanged" | |
else | |
echo $WAN_IP > /tmp/CURRENT_WAN_IP.txt | |
func_go; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment