Created
May 15, 2017 12:55
-
-
Save ast/feab12763c4580eb2f3ecb4ecf245bec to your computer and use it in GitHub Desktop.
Shell script that detects changes to your public ip address and updates your iwantmyname.com nameservers.
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
#!/usr/local/bin/bash | |
# Q: What is this? | |
# A: It's a shell script that updates what ip address your iwantmyname.com domain resolves to. | |
# I use it from cron. | |
# Q: What do I have to do? | |
# A: Add your username and password. Change the domain. Add it to your crontab. | |
set -e | |
user="youremail@yourdomain" | |
passwd="yourpasswd" | |
# try to read from previous run | |
if [ -f /tmp/wanip ]; then | |
prevwanip=$(</tmp/wanip) | |
fi | |
# get wanip | |
wanip=$(dig whoami.akamai.net. @ns1-1.akamaitech.net. +short) | |
# store | |
echo $wanip > /tmp/wanip | |
if [ "$wanip" != "$prevwanip" ]; then | |
echo "address changed from $prevwanip to $wanip" | |
curl -s -u "$user:$passwd" "https://iwantmyname.com/basicauth/ddns?hostname=www.sm6wjm.net,sm6wjm.net" | |
echo " sm6wjm.net" | |
curl -s -u "$user:$passwd" "https://iwantmyname.com/basicauth/ddns?hostname=www.albinstigo.me,albinstigo.me" | |
echo " albinstigo.me" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment