Skip to content

Instantly share code, notes, and snippets.

@pacmac
Last active December 19, 2019 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacmac/230f8db646463b26d8b56b72b75ac620 to your computer and use it in GitHub Desktop.
Save pacmac/230f8db646463b26d8b56b72b75ac620 to your computer and use it in GitHub Desktop.
linode update dns with APIV4
#!/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