Script to reboot a Comtrend AR-5381u Modem when connectivity is lost


# 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 > /dev/null 2>&1

if [ $? -ne 0 ]
        rm $COOKIE > /dev/null 2>&1

        export OUTPUT=`$CURL -v -c $COOKIE 'http://$MODEMUSERNAME:$MODEMPASSWORD@' 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@$SESSIONKEY" 2>> /tmp/output`

Leave a Reply

Your email address will not be published. Required fields are marked *