]>
Commit | Line | Data |
---|---|---|
7742e157 AF |
1 | #!/bin/bash |
2 | ||
3 | # ifup-ppp script for pppd-2.3.5 (with persist & demand options) ver 0.2 | |
4 | # Grzegorz Stanislawski <stangrze@open.net.pl> | |
5 | # Features: | |
6 | # - since persist option is included to pppd it''s no need to do werid loops | |
7 | # ifup-ppp script. This also makes your logfile grow slower when Your link | |
8 | # is down. | |
9 | # - chat-ppp? file with script for chat is now parsed by shell, so You can | |
10 | # include in it shell variables (for example $PHONE, $USERNAME) | |
11 | # You can define any variable in ifcfg-ppp? file and use it in chat-ppp? | |
12 | # You only have to add it's name into DATAFORCHAT variable | |
13 | # Note, that chat-ppp file is now parsed by shell, so you have to escape | |
14 | # with "\" all shell special characters like \$;:)(& etc. | |
15 | ||
16 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
17 | ||
18 | # ifup-post for PPP is handled through /etc/ppp/ip-up | |
19 | if [ "$1" != daemon ] ; then | |
20 | # disconnect stdin, out, err to disassociate from controlling tty | |
21 | # so that no HUPs will get through. | |
22 | $0 daemon $*& </dev/null >/dev/null 2>/dev/null | |
23 | exit 0 | |
24 | fi | |
25 | shift | |
26 | ||
27 | CONFIG=$1 | |
28 | cd /etc/sysconfig/network-scripts | |
29 | . network-functions | |
30 | source_config | |
31 | if [ -z "$HOLDOFF" ]; then | |
32 | HOLDOFF=30 | |
33 | fi | |
34 | if [ "$2" = "boot" -a "${ONBOOT}" = "no" ]; then | |
35 | exit | |
36 | fi | |
37 | [ -x /usr/sbin/pppd ] || { | |
38 | echo "/usr/sbin/pppd does not exist or is not executable" | |
39 | echo "ifup-ppp for $DEVICE exiting" | |
40 | logger -p daemon.info -t ifup-ppp \ | |
41 | "/usr/sbin/pppd does not exist or is not executable for $DEVICE" | |
42 | exit 1 | |
43 | } | |
44 | opts="lock" | |
45 | if [ "${PERSIST}" = "yes" ]; then | |
46 | opts="$opts persist holdoff $HOLDOFF" | |
47 | fi | |
48 | if [ "${DEMAND}" = "yes" ]; then | |
49 | #opts="$opts demand active-filter $ACTIVEFILTER idle $IDLE" | |
50 | opts="$opts demand " | |
51 | fi | |
52 | if [ "${HARDFLOWCTL}" = yes ] ; then | |
53 | opts="$opts modem crtscts" | |
54 | fi | |
55 | if [ "${ESCAPECHARS}" = yes ] ; then | |
56 | opts="$opts asyncmap 00000000" | |
57 | fi | |
58 | if [ "${DEFROUTE}" = yes ] ; then | |
59 | opts="$opts defaultroute" | |
60 | fi | |
61 | if [ -n "${MRU}" ] ; then | |
62 | opts="$opts mru ${MRU}" | |
63 | fi | |
64 | if [ -n "${MTU}" ] ; then | |
65 | opts="$opts mtu ${MTU}" | |
66 | fi | |
67 | if [ -n "${IPADDR}${REMIP}" ] ; then | |
68 | # if either IP address is set, the following will work. | |
69 | opts="$opts ${IPADDR}:${REMIP}" | |
70 | fi | |
71 | if [ -n "${PAPNAME}" ] ; then | |
72 | opts="$opts name ${PAPNAME}" | |
73 | fi | |
74 | if [ "${DEBUG}" = yes ] ; then | |
75 | opts="$opts debug" | |
76 | chatdbg="-v" | |
77 | fi | |
78 | if [ -n "${REPORTFILE}" ] ; then | |
79 | chatrpt="-r ${REPORTFILE}" | |
80 | fi | |
81 | (logger -p daemon.info -t ifup-ppp \ | |
82 | "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)& | |
83 | > /var/run/ppp-$DEVICE.dev | |
84 | ||
85 | if [ -n "${CHATSCRIPT}" ] ; then | |
86 | export chatdbg chatrpt CHATSCRIPT | |
87 | export $DATAFORCHAT | |
88 | /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ | |
89 | connect 'eval /usr/sbin/chat $chatdbg $chatrpt `cat ${CHATSCRIPT}`' \ | |
90 | remotename $DEVICE ipparam $DEVICE \ | |
91 | ${PPPOPTIONS} & | |
92 | else | |
93 | /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ | |
94 | remotename $DEVICE ipparam $DEVICE \ | |
95 | ${PPPOPTIONS} & | |
96 | fi | |
97 | echo "$!" > /var/run/ppp-$DEVICE.pid | |
98 |