1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash # default username for this model export MODEMUSERNAME=admin # default password for model export MODEMPASSWORD=user12345 export COOKIE= /tmp/cookie_jar export CURL= /usr/bin/curl export PING= /bin/ping export GREP= /bin/grep export CUT= /usr/bin/cut $PING -c 5 google.com > /dev/null 2>&1 if [ $? - ne 0 ] then rm $COOKIE > /dev/null 2>&1 export OUTPUT=`$CURL - v -c $COOKIE 'http://$MODEMUSERNAME:$MODEMPASSWORD@192.168.1.1/resetrouter.html' 2>> /tmp/output ` export SESSIONKEY=` echo "$OUTPUT" | $GREP var | $GREP sessionKey | $CUT -d "=" -f2 | $CUT -d "'" -f2` echo "kicking modem with session key $SESSIONKEY" export OUTPUT=`$CURL - v -c $COOKIE "http://$MODEMUSERNAME:$MODEMPASSWORD@192.168.1.1/rebootinfo.cgi?sessionKey=$SESSIONKEY" 2>> /tmp/output ` fi |