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