Skip to content

Instantly share code, notes, and snippets.

@hangya
Created April 7, 2014 18:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hangya/10026019 to your computer and use it in GitHub Desktop.
Save hangya/10026019 to your computer and use it in GitHub Desktop.
#!/bin/sh
IPFILE=/tmp/myip.txt
OLDIP=`cat $IPFILE`
MYIP=`/sbin/ifconfig ppp0 | grep inet | sed 's/.*inet addr:\([^ ]*\).*/\1/'`
CLIENT_ID=*****
API_KEY=*****
DOMAIN_ID=*****
RECORD_ID=*****
if [ "$MYIP" != "$OLDIP" ];
then
echo "IP address changed from $OLDIP to $MYIP"
# wget -O - -q "https://api.linode.com/?api_key=$API_KEY&api_action=domain.resource.update&domainid=$DOMAIN_ID&resourceid=$RECORD_ID&target=$MYIP"
wget -O - -q "https://api.digitalocean.com/domains/$DOMAIN_ID/records/$RECORD_ID/edit?data=$MYIP&client_id=$CLIENT_ID&api_key=$API_KEY"
echo $MYIP > $IPFILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment