Skip to content

Instantly share code, notes, and snippets.

@gonfva
Created November 17, 2013 22:33
Show Gist options
  • Select an option

  • Save gonfva/7519157 to your computer and use it in GitHub Desktop.

Select an option

Save gonfva/7519157 to your computer and use it in GitHub Desktop.
Script to update No-IP
#!/bin/bash
user=*****
password=******
useragent="SomethingUNIQUE/1 [email protected]"
testippath=******
oldIP=`cat $testippath/currentIP`
myIP=`curl -s "http://wtfismyip.com" | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"`
if [ $oldIP == $myIP ]
then
echo "Same IP, do nothing">>$testippath/log
exit 0
fi
if [ $myIP == "" ]
then
echo "ERROR. Empty OK. Do nothing">>$testippath/log
exit 0
fi
echo "Different IP, change to $myIP">>$testippath/log
url="http://$user:[email protected]/nic/update?hostname=whendoigo.no-ip.biz&myip=$myIP"
response=`curl -s -A $useragent $url|tail -1`
if [ $response == "good $myIP" ]
then
echo "SUCCESS. Update to $myIP">>$testippath/log
echo $myIP>$testippath/currentIP
exit 0
fi
if [ $response == "nochg $myIP"]
then
echo "WARNING. It says no change to $myIP">>$testippath/log
echo $myIP>$testippath/currentIP
exit 0
fi
echo "ERROR. Wrong response $response">>$testippath/log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment