100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 脚本重启电信天翼网关

脚本重启电信天翼网关

时间:2022-01-29 01:40:37

相关推荐

脚本重启电信天翼网关

背景:家里光猫经常断网,重启才能恢复。

光猫位置拔电源不方便,telnet登录重启需破解有风险,因此采用curl模拟登录web重启。最后通过其他脚本监测,实现断网时自动执行重启。

#!/bin/sha=$1 loginfo=`curl -s -L http://192.168.1.1/cgi-bin/luci -X POST -c /mnt/sdcard/myscript/cookies.txt -d 'username=用户名&psd=密码'`function mygetip() {ipinfo=`curl -s -b /mnt/sdcard/myscript/cookies.txt http://192.168.1.1/cgi-bin/luci/admin/settings/gwinfo?get=part&_=0.4801976069522096`echo $ipinfo | sed 's/,/\n/g' | grep -w WANIP}function myrestart() {runt=`curl -s -b /mnt/sdcard/myscript/cookies.txt http://192.168.1.1/cgi-bin/luci/admin/settings/gwstatus?_=0.5191398782674221 | sed 's/,/\n/g' | awk -F ':' '/sysTime/{print $2}'`if [ $runt -lt 120 ]; then echo -e "wating start..." else mytoken=$(echo $loginfo |sed 's/{/\n/g' | grep token |awk '/realRestart/{print $2}'| sed $'s/\'//g') curl -s -b /mnt/sdcard/myscript/cookies.txt http://192.168.1.1/cgi-bin/luci/admin/reboot -d 'token='$mytoken echo -e "Restating..." fi} if [ $a == 'restart' ]; thenif ping -W 3 -c 1 114.114.114.114 >/dev/null 2>&1thenmygetipelsemyrestartfielif [ $a == 'getip' ]; thenmygetip elseexitfiexit

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。