secgateway/kernel/rootfs_base/etc/ppp/ppp-4g

116 lines
1.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
lock_path="/var/run/"
run="pppd"
config="hc-interface.conf"
tmp="/tmp/ppp_tmp"
version=1.0
function start()
{
test -f /etc/ppp/peers/chat_connect || { echo "not install lte" ; exit 1; }
#删除默认网关
route del default
lock=$lock_path"$1.mypid"
#检测是否已运行
test ! -f $lock || { echo "$run apparently already active, start aborted!" ; exit 1; }
echo "start $run $1"
#记录下拨号时间
date +%s > $tmp
$run call fdd_tdd_wcdma_option > /var/log/ppp4g &
#pid
echo $! > $lock
}
function init()
{
if (lsusb |grep -q 19d2:1476)
then
if [ -r /dev/ttyUSB1 ]
then
echo "AT+ZSDT=1" >/dev/ttyUSB1
echo "AT+ZRST" > /dev/ttyUSB1
echo "4g init done"
else
echo "lte no match"
fi
else
echo "no found lte module"
fi
}
function stop()
{
lock=$lock_path"$1.mypid"
test -f $lock || { echo "$run may be sotped already" ; return 1; }
echo "stop $run $1"
#杀死进程
local pid=`cat $lock`
kill $pid
rm -f $lock
#echo "AT+ZRST" > /dev/ttyUSB1
#修改默认网关
#default_gw=`p_get wan.gw`
#if [ -z "$default_gw" ]; then
# route add default `p_get wan.iface`
#else
# route add default gw $default_gw `p_get wan.iface`
#fi
}
function status()
{
lock=$lock_path"$1.pid"
test ! -f $lock && echo "PPP-4G=off" || echo "PPP-4G=on"
now=`date +%s`
#已经拨号时间
echo ppp_keep_time=$(( $now - `cat $tmp` ))
}
# do it
case $1 in
reset|init)
stop
init
;;
on|start)
if [ -z "$2" ]; then
start "ppp0"
else
start $2
fi
;;
off|stop)
if [ -z "$2" ]; then
stop "ppp0"
else
stop $2
fi
;;
restart|--restart)
if [ -z "$2" ]; then
stop "ppp0"
sleep 2
start "ppp0"
else
stop $2
sleep 2
start $2
fi
;;
status|--status)
if [ -z "$2" ]; then
status "ppp0"
else
status $2
fi
;;
version)
echo "$version"
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac