1、start-ppp
#!/bin/sh
#quectel-pppd devname apn user password
echo "quectel-pppd options in effect:"
QL_DEVNAME=/dev/ttyUSB2
QL_APN=ctnet
QL_USER=card
QL_PASSWORD=card
if [ $# -ge 1 ]; then
QL_DEVNAME=$1
echo "devname $QL_DEVNAME # (from command line)"
else
echo "devname $QL_DEVNAME # (default)"
fi
if [ $# -ge 2 ]; then
QL_APN=$2
echo "apn $QL_APN # (from command line)"
else
echo "apn $QL_APN # (default)"
fi
if [ $# -ge 3 ]; then
QL_USER=$3
echo "user $QL_USER # (from command line)"
else
echo "user $QL_USER # (default)"
fi
if [ $# -ge 4 ]; then
QL_PASSWORD=$4
echo "password $QL_PASSWORD # (from command line)"
else
echo "password $QL_PASSWORD # (default)"
fi
CONNECT="'chat -s -v ABORT BUSY ABORT \"NO CARRIER\" ABORT \"NO DIALTONE\" ABORT ERROR ABORT \"NO ANSWER\" TIMEOUT 30 \
\"\" AT OK ATE0 OK ATI\;+CSUB\;+CSQ\;+CPIN?\;+COPS?\;+CGREG?\;\&D2 \
OK AT+CFUN=0 OK AT+CFUN=1 \
OK AT+CGDCONT=1,\\\"IP\\\",\\\"$QL_APN\\\",,0,0 OK ATD*99# CONNECT'"
pppd $QL_DEVNAME 115200 user "$QL_USER" password "$QL_PASSWORD" \
connect "'$CONNECT'" \
disconnect 'chat -s -v ABORT ERROR ABORT "NO DIALTONE" SAY "\nSending break to the modem\n" "" +++ "" +++ "" +++ SAY "\nGood bay\n"' \
noauth debug defaultroute noipdefault novj novjccomp noccp ipcp-accept-local ipcp-accept-remote ipcp-max-configure 30 local lock modem dump nodetach nocrtscts usepeerdns
2、start-ppp
#!/bin/sh
nohup ./ppp >> ./ppp.log 2>&1 &
exit
3、kill-ppp
#!/bin/sh
if [ -r /var/run/ppp0.pid ]; then
kill -INT `cat /var/run/ppp0.pid`
echo "PPP link to ppp0 terminated."
else
echo "ERROR: PPP link is not active on ppp0"
exit 0
fi
exit 1
4、/etc/ppp/ip-up
#!/bin/bash
# This file should not be modified -- make local changes to
# /etc/ppp/ip-up.local instead
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
LOGDEVICE=$6
REALDEVICE=$1
[ -f /etc/sysconfig/network-scripts/ifcfg-${LOGDEVICE} ] && /etc/sysconfig/network-scripts/ifup-post --realdevice ${REALDEVICE} ifcfg-${LOGDEVICE}
/etc/ppp/ip-up.ipv6to4 ${LOGDEVICE}
[ -x /etc/ppp/ip-up.local ] && /etc/ppp/ip-up.local "$@"
route add -net 0.0.0.0 ppp0
exit 0