Skip to content

Instantly share code, notes, and snippets.

@bitbybit
Last active May 1, 2019 01:29
Show Gist options
  • Save bitbybit/5756496 to your computer and use it in GitHub Desktop.
Save bitbybit/5756496 to your computer and use it in GitHub Desktop.
OpenDNS updater
#!/bin/sh
# Author: bluej774
# http://ubuntuforums.org/showthread.php?t=693788
UNAME=USERNAME # username
PWORD=PASSWORD # password (plaintext, sorry!)
TEMP=`mktemp` # temporary file
ERROR=5 # times to retry
trap cleanup 1 2 3 6
cleanup()
{
rm $TEMP
exit 1
}
update()
{
wget --quiet -O $TEMP 'https://'$UNAME':'$PWORD'@updates.dnsomatic.com/nic/update?'
if [ `cat $TEMP | grep -c good` = 1 ] || [ `cat $TEMP | grep -c nochg` = 1 ]
then
logger OpenDNS updated successfully
else
while [ $ERROR -gt 0 ]; do
ERROR=$(($ERROR-1))
sleep 10s
update
done
logger OpenDNS update failed
fi
}
update
rm $TEMP
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment