抑郁症健康,内容丰富有趣,生活中的好帮手!
抑郁症健康 > 4G pppd守护进行 断线重连 掉线重连

4G pppd守护进行 断线重连 掉线重连

时间:2023-04-03 20:19:32

相关推荐

使用脚本,即可实现。

#!/bin/bash#exit 0#echo "4g test"#ls /dev/ttyU*#cat /dev/ttyUSB2 &#echo -en "AT\r\n" > /dev/ttyUSB2#killall cat#exit 0echo "4g pppd"count=0#sleep 5#procedure='pppd'if [ "$(ps |grep "pppd call" |grep -v grep |awk '{print $1}')" ]; thenkillall pppd #结束PPPD进程fifor ((i=0; i<15; i++))dosleep 1if [ -f "/sys/class/gpio/gpio65/value" ]; thenbreakelseecho 65 > /sys/class/gpio/exportfidoneecho high > /sys/class/gpio/gpio65/directionfun_check_usb(){countCheckUSB=0while truedousleep 500000ret=`ls /dev/ttyUSB*`if [ "$ret" ]; thenecho $retbreakfilet countCheckUSB++if [ $countCheckUSB -gt 35 ]; thenrebootexit 0fidone}fun_check_usb#"/sys/class/net/eth0"#ifconfig eth0 down#ifconfig eth1 down#rm /etc/resolv.conf#ln -s /etc/ppp/resolv.conf /etc/resolv.confcp /etc/ppp/resolv.conf /etc/resolv.confpppd call wcdma-ec20 >/dev/null 2>&1 &sleep 12 #等待12秒fun_wait_ppp0(){countWait=0while truedousleep 500000if [ "$(ifconfig |grep ppp0)" ]; thenbreakfilet countWait++echo "pppd countWait=$countWait"if [ $countWait -gt 30 ]; thendatekillall pppd #结束PPPD进程echo "ppp0 is not existed"if [ $count -lt 15 ]; thencount=15fibreak#reboot#exit 0fidone}fun_wait_ppp0fun_route(){if [ ! "$(route -e |grep default |grep ppp0 |awk '{print $1}')" ]; thenif [ "$(ifconfig |grep ppp0)" ]; thenroute del defaultroute add default dev ppp0fifi}fun_route#---auto ppp---dns1="8.8.8.8"dns2="114.114.114.114"sleep 12 #等待12秒while truedoping -s 1 -c 5 $dns1 >/dev/null 2>&1 #去PING第一个DNSif [ "$?" != "0" ] #假如PING不通thenfun_routeping -s 1 -c 2 $dns2 >/dev/null 2>&1 #去PING第二个DNSif [ "$?" != "0" ]thendatekillall pppd #结束PPPD进程let count++echo "pppd count=$count"if [ $count -gt 30 ]; thenrebootexit 0elif [ $count -gt 15 ]; thenecho 0 > /sys/class/gpio/gpio65/valueusleep 500000echo 1 > /sys/class/gpio/gpio65/value#ttyUSB* is existed about 10 second#sleep 12 #等待12秒fisleep 12 #等待12秒fun_check_usb#ifconfig eth0 down#ifconfig eth1 down#cp /etc/ppp/resolv.conf /etc/resolv.confpppd call wcdma-ec20 >/dev/null 2>&1 & #再去拨号sleep 12 #等待12秒fun_wait_ppp0fun_routesleep 5elsecount=0sleep 60 #如果是PINGDNS2通的话就直接等待5秒fielsecount=0sleep 120 #如果是PINGDNS1通的话就直接等待5秒(一般要设置多长时间去PING请改这里)fidone

如果觉得《4G pppd守护进行 断线重连 掉线重连》对你有帮助,请点赞、收藏,并留下你的观点哦!

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