Created
November 17, 2013 22:33
-
-
Save gonfva/7519157 to your computer and use it in GitHub Desktop.
Script to update No-IP
This file contains hidden or 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/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