Last active
December 16, 2015 16:59
-
-
Save Cameron-D/5466932 to your computer and use it in GitHub Desktop.
Makes my modem fetch a new IP when I'm blocked from Posterous. Install `sl` for burning trains. Choo choo.
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 | |
| while : | |
| do | |
| curl -o /dev/null --url http://posterous.com/ >/dev/null 2>&1 | |
| rc=$? | |
| T="$(date +%H:%M:%S)" | |
| if [[ $rc != 0 ]] ; then | |
| echo "$T Blocked. Getting new IP..." | |
| $HOME/rebootrouter.ex >/dev/null 2>&1 | |
| sleep 60 # wait for the reload to complete | |
| IP=`curl -s http://ifconfig.me/` | |
| T="$(date +%H:%M:%S)" | |
| echo "$T Got new IP: $IP" | |
| echo "$IP" >> iplist.txt | |
| else | |
| echo "$T Not blocked, lets go!" | |
| fi | |
| sl -a & | |
| sleep 30 | |
| done |
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/bin/expect | |
| set timeout 20 | |
| set user "admin" | |
| set password "" | |
| spawn telnet 192.168.1.254 | |
| expect "Login: " | |
| send "$user\n" | |
| expect "Password: " | |
| send "$password\n" | |
| sleep 1 | |
| #send "reboot\n" | |
| send "ppp config ppp0 down\n" | |
| sleep 10 | |
| send "ppp config ppp0 up\n" | |
| sleep 10 | |
| send "exit\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment