]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
b0443108 | 2 | # |
ec8b15cb | 3 | # $Id$ |
b0443108 | 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. | |
a6c22d3d | 17 | |
7742e157 AF |
18 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
19 | ||
20 | # ifup-post for PPP is handled through /etc/ppp/ip-up | |
7742e157 | 21 | |
f3002e12 JK |
22 | . /etc/sysconfig/network |
23 | . /etc/rc.d/init.d/functions | |
baa6b418 | 24 | . /etc/sysconfig/network-scripts/functions.network |
8b3e2b71 | 25 | |
a6c22d3d | 26 | CONFIG=$1 |
7742e157 | 27 | source_config |
de1fc6ce JR |
28 | # set all major variables |
29 | setup_ip_param | |
30 | ||
dd4a755f | 31 | if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then |
7742e157 AF |
32 | exit |
33 | fi | |
a6c22d3d AM |
34 | if [ ! -x /usr/sbin/pppd ]; then |
35 | nls "/usr/sbin/pppd does not exist or is not executable" | |
36 | nls "ifup-ppp for %s exiting" "$DEVICE" | |
7742e157 | 37 | logger -p daemon.info -t ifup-ppp \ |
a6c22d3d | 38 | "$(nls '/usr/sbin/pppd does not exist or is not executable for %s' "$DEVICE")" |
7742e157 | 39 | exit 1 |
a6c22d3d | 40 | fi |
3ed6009f | 41 | |
de1fc6ce JR |
42 | # modprobe ppp in case of kernel with devfs |
43 | # (/dev/ppp is missing and ppp fails without this) --misiek | |
a6c22d3d | 44 | [ -c /dev/.devfsd ] && modprobe -s -k char-major-108 |
de1fc6ce | 45 | |
7742e157 | 46 | opts="lock" |
a6c22d3d AM |
47 | |
48 | if [ -z "${REPORTFILE}" ] ; then | |
49 | REPORTFILE=/dev/null | |
50 | fi | |
51 | ||
c3bd5d9f AM |
52 | if [ -n "${PPPOE_DEV}" ]; then |
53 | if is_yes "${PPPOE_KERNEL}"; then | |
54 | modprobe -s -k pppoe | |
55 | MODEMMODE="plugin rp-pppoe.so" | |
56 | MODEMPORT="${PPPOE_DEV}" | |
57 | else | |
58 | MODEMMODE="pty" | |
59 | MODEMPORT="pppoe -I ${PPPOE_DEV} ${PPPOE_OPT}" | |
60 | fi | |
61 | else | |
62 | if is_no "${DIRECT_CONNECT}" || [ -z "${DIRECT_CONNECT}" ]; then | |
63 | ||
64 | PEERCONF=/etc/ppp/peers/${DEVNAME} | |
65 | ||
66 | if [ ! -f ${PEERCONF} ]; then | |
67 | if [ -z "${WVDIALSECT}" ]; then | |
a6c22d3d | 68 | # XXX: REPORTFILE support is problematic here --misiek |
c3bd5d9f AM |
69 | [ -f "${CHATSCRIPT}" ] || CHATSCRIPT=/etc/sysconfig/interfaces/data/chat-${PARENTDEVNAME} |
70 | if [ ! -f "${CHATSCRIPT}" ]; then | |
a5fd33bf | 71 | nls '%s does not exist' "${CHATSCRIPT}" |
c3bd5d9f AM |
72 | nls 'ifup-ppp for %s exiting' "${DEVNAME}" |
73 | logger -p daemon.info -t ifup-ppp \ | |
a5fd33bf | 74 | "$(nls '%s does not exist for %s' "${CHATSCRIPT}" "${DEVICE}")" |
c3bd5d9f AM |
75 | exit 1 |
76 | fi | |
a6c22d3d | 77 | fi |
c3bd5d9f AM |
78 | logger -s -p daemon.notice -t ifup-ppp "$(nls 'Setting up a new %s config file' "${PEERCONF}")" |
79 | if [ -f /etc/ppp/peers/${DEVICE} ]; then | |
80 | cp -f /etc/ppp/peers/${DEVICE} ${PEERCONF} | |
81 | else | |
82 | touch ${PEERCONF} | |
83 | fi | |
84 | if [ "${WVDIALSECT}" ]; then | |
c4e87d18 | 85 | echo "connect \"/usr/bin/wvdial --chat ${WVDIALSECT} --config /etc/wvdial.conf >> ${REPORTFILE} 2>&1 \"" >> ${PEERCONF} |
c3bd5d9f AM |
86 | else |
87 | if is_yes "${DEBUG}"; then | |
88 | chatdbg="-v" | |
89 | fi | |
90 | echo "connect \"/usr/sbin/chat $chatdbg -f ${CHATSCRIPT} -r ${REPORTFILE} ${chatdbg}\"" >> ${PEERCONF} | |
a6c22d3d | 91 | fi |
a6c22d3d | 92 | fi |
c3bd5d9f AM |
93 | |
94 | opts="$opts call ${DEVNAME}" | |
a6c22d3d | 95 | fi |
a6c22d3d AM |
96 | fi |
97 | ||
98 | if [ -z "$HOLDOFF" ]; then | |
99 | HOLDOFF=30 | |
100 | fi | |
dd4a755f | 101 | if is_yes "${PERSIST}"; then |
3ed6009f | 102 | if [ -z "${MAXFAIL}" ]; then |
103 | MAXFAIL="0" | |
104 | fi | |
7b4e96e8 | 105 | opts="$opts persist holdoff $HOLDOFF maxfail $MAXFAIL" |
7742e157 | 106 | fi |
dd4a755f | 107 | if is_yes "${DEMAND}"; then |
3ed6009f | 108 | if [ -z "${IDLE}" ]; then |
109 | IDLE="0" | |
110 | fi | |
a6c22d3d AM |
111 | opts="$opts demand ktune idle ${IDLE}" |
112 | fi | |
113 | if ! is_no "${HARDFLOWCTL}"; then | |
114 | opts="$opts crtscts" | |
7742e157 | 115 | fi |
a6c22d3d AM |
116 | if is_yes "${MODEMCTL}"; then |
117 | opts="$opts modem" | |
7742e157 | 118 | fi |
dd4a755f | 119 | if is_yes "${ESCAPECHARS}"; then |
d29c401a | 120 | opts="$opts asyncmap FFFFFFFF" |
a6c22d3d | 121 | else |
7742e157 AF |
122 | opts="$opts asyncmap 00000000" |
123 | fi | |
a6c22d3d | 124 | if ! is_no "${DEFROUTE}"; then |
de1fc6ce JR |
125 | # pppd will no longer delete an existing default route |
126 | # so we have to help it out a little here. | |
127 | ip route del 0/0 > /dev/null 2>&1 | |
7742e157 AF |
128 | opts="$opts defaultroute" |
129 | fi | |
a6c22d3d | 130 | if ! is_no "${PEERDNS}"; then |
de1fc6ce JR |
131 | opts="$opts usepeerdns" |
132 | fi | |
7742e157 AF |
133 | if [ -n "${MRU}" ] ; then |
134 | opts="$opts mru ${MRU}" | |
135 | fi | |
136 | if [ -n "${MTU}" ] ; then | |
137 | opts="$opts mtu ${MTU}" | |
138 | fi | |
de1fc6ce | 139 | if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}${REMIP}" ] ; then |
7742e157 | 140 | # if either IP address is set, the following will work. |
de1fc6ce JR |
141 | opts="$opts ${IP4ADDR}:${REMIP}" |
142 | fi | |
a6c22d3d AM |
143 | if is_yes "$IPV6_NETWORKING"; then |
144 | if is_yes "$IPV6_PPP"; then | |
de1fc6ce JR |
145 | if [ -n "${IP6ADDR}${REMIP6}" ] ; then |
146 | opts="$opts ipv6 ${IP6ADDR},${REMIP6}" | |
147 | elif is_yes "$IPV6_CP_USEV4"; then | |
148 | opts="$opts ipv6cp-use-ipaddr" | |
149 | elif is_yes "$IPV6_CP_PERSISTENT"; then | |
150 | opts="$opts ipv6cp-use-persistent" | |
151 | fi | |
a6c22d3d AM |
152 | elif is_no "$IPV6_PPP"; then |
153 | opts="$opts noipv6" | |
154 | fi | |
155 | elif is_no "$IPV6_NETWORKING"; then | |
156 | opts="$opts noipv6" | |
157 | fi | |
158 | if is_yes "${IPX_PPP}"; then | |
159 | opts="$opts ipx" | |
160 | if [ -n "${IPX_PPP_NETWORK}" ]; then | |
161 | opts="$opts ipx-network ${IPX_PPP_NETWORK}" | |
162 | fi | |
163 | if [ -n "${IPX_PPP_NODE}" ]; then | |
164 | opts="$opts ipx-node ${IPX_PPP_NODE}" | |
165 | fi | |
166 | if [ -n "${IPX_PPP_ROUTING}" ]; then | |
167 | opts="$opts ipx-routing ${IPX_PPP_ROUTING}" | |
168 | fi | |
7742e157 | 169 | fi |
c3bd5d9f | 170 | |
7742e157 | 171 | if [ -n "${PAPNAME}" ] ; then |
a6c22d3d | 172 | opts="$opts user ${PAPNAME}" |
7742e157 | 173 | fi |
200ca1e9 JK |
174 | if [ -n "${REMOTENAME}" ] ; then |
175 | opts="$opts remotename ${REMOTENAME}" | |
176 | fi | |
dd4a755f | 177 | if is_yes "${DEBUG}"; then |
7742e157 | 178 | opts="$opts debug" |
7742e157 | 179 | fi |
a6c22d3d AM |
180 | if is_yes "${AUTH}"; then |
181 | opts="$opts auth" | |
182 | elif is_no "${AUTH}"; then | |
183 | opts="$opts noauth" | |
7742e157 | 184 | fi |
7742e157 | 185 | |
c3bd5d9f AM |
186 | if ! is_no "${UNIT}"; then |
187 | UNIT=$(echo "${DEVICE}" | awk ' { gsub(/ppp/,NUL); print $0} ') | |
188 | opts="$opts unit ${UNIT}" | |
189 | fi | |
190 | ||
c4e87d18 AM |
191 | MODEM="${MODEMPORT}"; export MODEM |
192 | ||
a6c22d3d | 193 | (logger -p daemon.info -t ifup-ppp \ |
c3bd5d9f | 194 | $(nls 'pppd started for %s on device %s at speed %s' "$DEVICE" "$MODEMPORT" "${LINESPEED:-(unspecified)} on unit ${UNIT}") &)& |
de1fc6ce | 195 | |
c3bd5d9f | 196 | /usr/sbin/pppd $opts ${MODEMMODE} "${MODEMPORT}" ${LINESPEED} \ |
a6c22d3d AM |
197 | ipparam ${DEVNAME} linkname ${DEVNAME} \ |
198 | ${PPPOPTIONS} | |
199 | ||
de1fc6ce JR |
200 | # This must be last line ! |
201 | # vi:syntax=sh:tw=78:ts=8:sw=4 | |
a6c22d3d | 202 |