Skip to content

Instantly share code, notes, and snippets.

@jeffgeiger
Created May 19, 2016 21:25
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 jeffgeiger/cc8453750b3e5601802084314c82bb48 to your computer and use it in GitHub Desktop.
Save jeffgeiger/cc8453750b3e5601802084314c82bb48 to your computer and use it in GitHub Desktop.
Dynamic IP update with notifications
#!/bin/bash
CURRENTIP=$(curl http://ipinfo.io/ip 2>/dev/nulll)
if [[ $CURRENTIP != $(cat /tmp/ipdata) ]]; then
echo "CHANGE: $CURRENTIP - $(date) FROM: $(cat /tmp/ipdata)"
/usr/sbin/ez-ipupdate -c /etc/ez-ipupdate/default.conf -a $CURRENTIP
echo $CURRENTIP > /tmp/ipdata
curl -Lk -XPOST -d "apikey=xxxxxxxxxxxxxxxxxx&priority=-2&application=Labs&event=IP%20Change&description=New%20IP%3A%20${CURRENTIP}" https://api.prowlapp.com/publicapi/add
curl -A "DDUpdater - Dynamic DNS Updater - 0.0.1" -u 'xxxx.xxxxxxxx@xxxxxx.xxx:xxxxxxxxxx' https://updates.dnsomatic.com/nic/update?hostname=Home
else
echo "ALL GOOD - $(date) - $CURRENTIP"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment