Last active
October 17, 2016 09:04
-
-
Save neftaly/4cf67bb83909addce790 to your computer and use it in GitHub Desktop.
Automatically update Adfreetime.com IP address (for anti-region-blocking)
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 | |
# Automatically update Adfreetime.com IP address (for anti-region-blocking) | |
# | |
# Consider adding the following to /etc/dhcp/dhclient.conf: | |
# prepend domain-name-servers 192.169.71.180, 208.110.81.50, 192.254.74.200; | |
# | |
# Consider adding "ipv6.disable=1" to boot options in "/etc/default/grub", | |
# Then run "update-grub" | |
# | |
adfreetime_email="[email protected]" # Set account name here | |
ipfile="/tmp/wanipaddr" | |
newip=$(dig +short myip.opendns.com @resolver1.opendns.com) | |
if [ -f "$ipfile" ]; then | |
oldip=$(cat "$ipfile") | |
else | |
oldip="0.0.0.0" | |
fi | |
if [ ! $oldip = $newip ]; then | |
response=$(wget -qO- "http://login.adfreetime.com/cron.php?email=$adfreetime_email") | |
echo "$response" | |
if [ "$response" = "IP: $newip is activated!" ]; then | |
echo "$newip" > "$ipfile" | |
else | |
exit 1 | |
fi | |
else | |
echo "IP: $newip has not changed." | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment