]>
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 |
74a7f2e4 | 32 | exit |
7742e157 | 33 | fi |
a6c22d3d | 34 | if [ ! -x /usr/sbin/pppd ]; then |
74a7f2e4 | 35 | nls "%s does not exist or is not executable" "/usr/sbin/pppd" |
36 | nls "%s for %s exiting" "ifup-ppp" "$DEVICE" | |
7742e157 | 37 | logger -p daemon.info -t ifup-ppp \ |
74a7f2e4 | 38 | "$(nls '%s does not exist or is not executable for %s' \ |
39 | "/usr/sbin/pppd" "$DEVICE")" | |
7742e157 | 40 | exit 1 |
a6c22d3d | 41 | fi |
3ed6009f | 42 | |
f3fb1a0c AM |
43 | # modprobe ppp modules (udev and devfsd case) |
44 | [ ! -e /dev/ppp ] && 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 | |
995264bd | 61 | elif is_yes "${PPPOA_EAGLE}"; then |
63dc9b50 MK |
62 | EAGLECTRL="/usr/sbin/adictrl" |
63 | if [ ! -x $EAGLECTRL ]; then | |
6bd0b912 | 64 | EAGLECTRL="/usr/sbin/eaglectrl" |
6bd0b912 MK |
65 | fi |
66 | if [ ! -x $EAGLECTRL ]; then | |
67 | nls "%s does not exist or is not executable" "$EAGLECTRL" | |
68 | nls "%s for %s exiting" "ifup-ppp" "$DEVICE" | |
69 | exit 1 | |
70 | fi | |
71 | $EAGLECTRL -w | |
72 | PPPOA_IFACE=$( $EAGLECTRL -i 2>/dev/null) | |
198aac19 AM |
73 | if [ -z "$PPPOA_IFACE" ]; then |
74 | PPPOA_IFACE="(unknown)" | |
75 | else | |
76 | ip link set "$PPPOA_IFACE" up | |
77 | fi | |
995264bd AM |
78 | MODEMMODE="pty" |
79 | MODEMPORT="pppoa -I ${PPPOA_IFACE} ${PPPOA_OPT}" | |
86b5dc44 AM |
80 | elif is_yes "${PPPOA_SPEEDTOUCH}"; then |
81 | if is_yes "${PPPOA_KERNEL}"; then | |
058c2faf | 82 | modprobe -s -k speedtch |
86b5dc44 AM |
83 | modprobe -s -k pppoatm |
84 | modem_run -k -s -f "${PPPOA_FIRMWARE}" | |
85 | MODEMMODE="plugin pppoatm.so" | |
86 | MODEMPORT="${PPPOA_VPI}.${PPPOA_VCI}" | |
87 | else | |
88 | modem_run -s -f "${PPPOA_FIRMWARE}" | |
89 | MODEMMODE="pty" | |
90 | MODEMPORT="pppoa3 -v1 -c -vpi ${PPPOA_VPI} -vci ${PPPOA_VCI} ${PPPOA_OPT}" | |
91 | fi | |
c3bd5d9f AM |
92 | else |
93 | if is_no "${DIRECT_CONNECT}" || [ -z "${DIRECT_CONNECT}" ]; then | |
94 | ||
95 | PEERCONF=/etc/ppp/peers/${DEVNAME} | |
96 | ||
97 | if [ ! -f ${PEERCONF} ]; then | |
98 | if [ -z "${WVDIALSECT}" ]; then | |
a6c22d3d | 99 | # XXX: REPORTFILE support is problematic here --misiek |
c3bd5d9f AM |
100 | [ -f "${CHATSCRIPT}" ] || CHATSCRIPT=/etc/sysconfig/interfaces/data/chat-${PARENTDEVNAME} |
101 | if [ ! -f "${CHATSCRIPT}" ]; then | |
a5fd33bf | 102 | nls '%s does not exist' "${CHATSCRIPT}" |
c3bd5d9f AM |
103 | nls 'ifup-ppp for %s exiting' "${DEVNAME}" |
104 | logger -p daemon.info -t ifup-ppp \ | |
a5fd33bf | 105 | "$(nls '%s does not exist for %s' "${CHATSCRIPT}" "${DEVICE}")" |
c3bd5d9f AM |
106 | exit 1 |
107 | fi | |
a6c22d3d | 108 | fi |
c3bd5d9f AM |
109 | logger -s -p daemon.notice -t ifup-ppp "$(nls 'Setting up a new %s config file' "${PEERCONF}")" |
110 | if [ -f /etc/ppp/peers/${DEVICE} ]; then | |
111 | cp -f /etc/ppp/peers/${DEVICE} ${PEERCONF} | |
112 | else | |
113 | touch ${PEERCONF} | |
114 | fi | |
115 | if [ "${WVDIALSECT}" ]; then | |
c4e87d18 | 116 | echo "connect \"/usr/bin/wvdial --chat ${WVDIALSECT} --config /etc/wvdial.conf >> ${REPORTFILE} 2>&1 \"" >> ${PEERCONF} |
c3bd5d9f AM |
117 | else |
118 | if is_yes "${DEBUG}"; then | |
119 | chatdbg="-v" | |
120 | fi | |
dec1e742 AM |
121 | if [ -n "${DATAFORCHAT}" ]; then |
122 | chatreadenv=-E | |
123 | fi | |
124 | echo "connect \"/usr/sbin/chat $chatreadenv -f ${CHATSCRIPT} -r ${REPORTFILE} ${chatdbg}\"" >> ${PEERCONF} | |
a6c22d3d | 125 | fi |
a6c22d3d | 126 | fi |
74a7f2e4 | 127 | |
c3bd5d9f | 128 | opts="$opts call ${DEVNAME}" |
a6c22d3d | 129 | fi |
a6c22d3d AM |
130 | fi |
131 | ||
132 | if [ -z "$HOLDOFF" ]; then | |
74a7f2e4 | 133 | HOLDOFF=30 |
a6c22d3d | 134 | fi |
dd4a755f | 135 | if is_yes "${PERSIST}"; then |
74a7f2e4 | 136 | if [ -z "${MAXFAIL}" ]; then |
137 | MAXFAIL="0" | |
138 | fi | |
139 | opts="$opts persist holdoff $HOLDOFF maxfail $MAXFAIL" | |
7742e157 | 140 | fi |
dd4a755f | 141 | if is_yes "${DEMAND}"; then |
74a7f2e4 | 142 | if [ -z "${IDLE}" ]; then |
143 | IDLE="0" | |
144 | fi | |
145 | opts="$opts demand ktune idle ${IDLE}" | |
a6c22d3d AM |
146 | fi |
147 | if ! is_no "${HARDFLOWCTL}"; then | |
74a7f2e4 | 148 | opts="$opts crtscts" |
7742e157 | 149 | fi |
a6c22d3d AM |
150 | if is_yes "${MODEMCTL}"; then |
151 | opts="$opts modem" | |
7742e157 | 152 | fi |
dd4a755f | 153 | if is_yes "${ESCAPECHARS}"; then |
74a7f2e4 | 154 | opts="$opts asyncmap FFFFFFFF" |
a6c22d3d | 155 | else |
74a7f2e4 | 156 | opts="$opts asyncmap 00000000" |
7742e157 | 157 | fi |
40e44c36 | 158 | if is_yes "${DEFROUTE}"; then |
74a7f2e4 | 159 | # pppd will no longer delete an existing default route |
160 | # so we have to help it out a little here. | |
161 | ip route del 0/0 > /dev/null 2>&1 | |
162 | opts="$opts defaultroute" | |
40e44c36 | 163 | elif ! is_no "${DEFROUTE}"; then |
74a7f2e4 | 164 | opts="$opts defaultroute" |
7742e157 | 165 | fi |
a6c22d3d | 166 | if ! is_no "${PEERDNS}"; then |
74a7f2e4 | 167 | opts="$opts usepeerdns" |
de1fc6ce | 168 | fi |
7742e157 | 169 | if [ -n "${MRU}" ] ; then |
74a7f2e4 | 170 | opts="$opts mru ${MRU}" |
7742e157 AF |
171 | fi |
172 | if [ -n "${MTU}" ] ; then | |
74a7f2e4 | 173 | opts="$opts mtu ${MTU}" |
7742e157 | 174 | fi |
de1fc6ce | 175 | if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}${REMIP}" ] ; then |
74a7f2e4 | 176 | # if either IP address is set, the following will work. |
177 | opts="$opts ${IP4ADDR}:${REMIP}" | |
de1fc6ce | 178 | fi |
a6c22d3d | 179 | if is_yes "$IPV6_NETWORKING"; then |
74a7f2e4 | 180 | if is_yes "$IPV6_PPP"; then |
de1fc6ce JR |
181 | if [ -n "${IP6ADDR}${REMIP6}" ] ; then |
182 | opts="$opts ipv6 ${IP6ADDR},${REMIP6}" | |
183 | elif is_yes "$IPV6_CP_USEV4"; then | |
184 | opts="$opts ipv6cp-use-ipaddr" | |
185 | elif is_yes "$IPV6_CP_PERSISTENT"; then | |
186 | opts="$opts ipv6cp-use-persistent" | |
187 | fi | |
74a7f2e4 | 188 | elif is_no "$IPV6_PPP"; then |
189 | opts="$opts noipv6" | |
190 | fi | |
a6c22d3d AM |
191 | elif is_no "$IPV6_NETWORKING"; then |
192 | opts="$opts noipv6" | |
193 | fi | |
194 | if is_yes "${IPX_PPP}"; then | |
195 | opts="$opts ipx" | |
196 | if [ -n "${IPX_PPP_NETWORK}" ]; then | |
197 | opts="$opts ipx-network ${IPX_PPP_NETWORK}" | |
198 | fi | |
199 | if [ -n "${IPX_PPP_NODE}" ]; then | |
200 | opts="$opts ipx-node ${IPX_PPP_NODE}" | |
201 | fi | |
202 | if [ -n "${IPX_PPP_ROUTING}" ]; then | |
203 | opts="$opts ipx-routing ${IPX_PPP_ROUTING}" | |
204 | fi | |
7742e157 | 205 | fi |
c3bd5d9f | 206 | |
7742e157 | 207 | if [ -n "${PAPNAME}" ] ; then |
74a7f2e4 | 208 | opts="$opts user ${PAPNAME}" |
7742e157 | 209 | fi |
200ca1e9 | 210 | if [ -n "${REMOTENAME}" ] ; then |
74a7f2e4 | 211 | opts="$opts remotename ${REMOTENAME}" |
200ca1e9 | 212 | fi |
dd4a755f | 213 | if is_yes "${DEBUG}"; then |
74a7f2e4 | 214 | opts="$opts debug" |
7742e157 | 215 | fi |
a6c22d3d | 216 | if is_yes "${AUTH}"; then |
74a7f2e4 | 217 | opts="$opts auth" |
a6c22d3d | 218 | elif is_no "${AUTH}"; then |
74a7f2e4 | 219 | opts="$opts noauth" |
7742e157 | 220 | fi |
f42fe46b | 221 | if is_yes "$PLUGIN_IFCFG_PASSWORD" && [ -n "$PASSWORD" ]; then |
74a7f2e4 | 222 | if [ -f "$CONFIG" ]; then |
223 | ifcfg_password_config="$CONFIG" | |
224 | else | |
225 | ifcfg_password_config="/etc/sysconfig/interfaces/$CONFIG" | |
226 | fi | |
227 | opts="$opts plugin ifcfg-password.so ifcfg $ifcfg_password_config" | |
8175323a | 228 | fi |
7742e157 | 229 | |
c3bd5d9f AM |
230 | if ! is_no "${UNIT}"; then |
231 | UNIT=$(echo "${DEVICE}" | awk ' { gsub(/ppp/,NUL); print $0} ') | |
232 | opts="$opts unit ${UNIT}" | |
233 | fi | |
234 | ||
c4e87d18 AM |
235 | MODEM="${MODEMPORT}"; export MODEM |
236 | ||
a6c22d3d | 237 | (logger -p daemon.info -t ifup-ppp \ |
74a7f2e4 | 238 | "$(nls 'pppd started for %s on device %s at speed %s' "$DEVICE" \ |
239 | "$MODEMPORT" "${LINESPEED:-(unspecified)} on unit ${UNIT}")" &)& | |
de1fc6ce | 240 | |
dec1e742 | 241 | if [ -n "${DATAFORCHAT}" ]; then |
74a7f2e4 | 242 | export $DATAFORCHAT |
dec1e742 | 243 | fi |
c3bd5d9f | 244 | /usr/sbin/pppd $opts ${MODEMMODE} "${MODEMPORT}" ${LINESPEED} \ |
74a7f2e4 | 245 | ipparam ${DEVNAME} linkname ${DEVNAME} \ |
246 | ${PPPOPTIONS} | |
a6c22d3d | 247 | |
de1fc6ce | 248 | # This must be last line ! |
31abb21f | 249 | # vi:syntax=sh:ts=8:sw=4 |