Last active
May 1, 2019 01:29
-
-
Save bitbybit/5756496 to your computer and use it in GitHub Desktop.
OpenDNS updater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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