Skip to content

Instantly share code, notes, and snippets.

@pacmac
Last active December 19, 2019 04:46
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/3acc357bef158d7fa875b875c80ec8cb to your computer and use it in GitHub Desktop.
Save pacmac/3acc357bef158d7fa875b875c80ec8cb to your computer and use it in GitHub Desktop.
#!/bin/sh
LINODE_API_KEY="12345"
DOMAIN_ID="12345"
SUB_NAME="my.sub.domain.com"
WAN_IP=`curl -s ipecho.net/plain`;
OLD_WAN_IP=`cat /tmp/CURRENT_WAN_IP.txt`
if [ "$WAN_IP" = "$OLD_WAN_IP" ]; then
echo "IP Unchanged"
else
echo $WAN_IP > /tmp/CURRENT_WAN_IP.txt
curl -H "Authorization: Bearer $LINODE_API_KEY" -H "Content-Type: application/json" -X POST -d "{\"type\": \"A\",\"target\": \"$WAN_IP\",\"name\": \"$SUB_NAME\"}" https://api.linode.com/v4/domains/$DOMAIN_ID/records;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment