forked from Freetz/freetz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.ppp
executable file
·112 lines (101 loc) · 2.4 KB
/
rc.ppp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
DAEMON=ppp
. /etc/init.d/modlibrc
disconnect() {
killall -9 ppp_dialer 2>/dev/null
killall pppd 2>/dev/null
sleep 2
cnt=17
while [ -n "$(pidof pppd)" ] && [ $cnt -gt 0 ]; do
killall -9 pppd 2>/dev/null
let cnt--
sleep 1
done
[ -z "$PPP_LOGFILE" ] || echo -e "TERMINATED\n$(date "+%Y-%m-%d %H:%M,%S")\n##\n" >> $PPP_LOGFILE
[ -e "$PPP_SCRIPT_HUP" ] && . $PPP_SCRIPT_HUP
echo "#" > /etc/ppp/resolv.conf
[ -n "$(pidof pppd)" ] && return 1
return 0
}
start() {
echo -n 'Starting ppp-cgi ... '
if [ -n "$(pidof ppp_observer ppp_dialer pppd)" ]; then
echo 'already running.'
exit 1
fi
modprobe option
modprobe ppp_generic
modprobe ppp_async
modprobe ppp-deflate
modprobe slhc
start-stop-daemon -n ppp_observer -a /mod/etc/default.ppp/ppp_observer -b -q -S
[ -n "$PPP_DIAGTTY" ] && start-stop-daemon -n ppp_logger -a /mod/etc/default.ppp/ppp_logger -b -q -S
echo 'done.'
}
stop() {
echo -n 'Stopping ppp-cgi ... '
if [ -z "$(pidof ppp_observer ppp_dialer pppd)" ]; then
echo 'not running.'
return 1
fi
killall -9 ppp_observer 2>/dev/null
killall -9 ppp_logger 2>/dev/null
kill $(cat /var/run/ppp_logger.pid 2>/dev/null) 2>/dev/null
rm -rf /tmp/ppp_logger.tmp 2>/dev/null
disconnect
if [ $? -ne 0 ]; then
echo 'failed.'
return 1
else
echo 'done.'
fi
}
case $1 in
""|load)
[ ! -d "/mod/etc/ppp" ] && mkdir -p /mod/etc/ppp
[ ! -d "/tmp/flash/ppp/peers" ] && mkdir -p /tmp/flash/ppp/peers
[ ! -e "/mod/etc/ppp/peers" ] && ln -s /tmp/flash/ppp/peers /mod/etc/ppp/peers
[ ! -e "/tmp/flash/ppp/peers/dun" ] && /mod/etc/default.${DAEMON}/peers_options > /tmp/flash/ppp/peers/dun
[ ! -e "/tmp/flash/ppp/peers/dun.chat" ] && /mod/etc/default.${DAEMON}/peers_chat > /tmp/flash/ppp/peers/dun.chat
modreg cgi 'ppp' 'PPP'
modreg daemon $DAEMON
modreg status ppp ppp-cgi ppplog
modreg file ppp 'peers_options' 'PEERS: options' 0 "peers_options"
modreg file ppp 'peers_chat' 'PEERS: chat' 0 "peers_chat"
modlib_start $PPP_ENABLED
;;
unload)
modunreg cgi 'ppp'
modunreg daemon $DAEMON
modunreg status ppp ppplog
modunreg file ppp
stop
;;
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
status)
if [ -n "$(pidof ppp_observer ppp_dialer pppd)" ]; then
echo 'running'
else
echo 'stopped'
fi
;;
disconnect)
disconnect
exit $?
;;
*)
echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2
exit 1
;;
esac
exit 0