]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
b0443108 | 2 | # |
b0443108 | 3 | # |
7742e157 AF |
4 | # ifup-ppp script for pppd-2.3.5 (with persist & demand options) ver 0.2 |
5 | # Grzegorz Stanislawski <stangrze@open.net.pl> | |
6 | # Features: | |
b9fbc0ca | 7 | # - since persist option is included to pppd it's no need to do werid loops |
7742e157 AF |
8 | # ifup-ppp script. This also makes your logfile grow slower when Your link |
9 | # is down. | |
10 | # - chat-ppp? file with script for chat is now parsed by shell, so You can | |
11 | # include in it shell variables (for example $PHONE, $USERNAME) | |
12 | # You can define any variable in ifcfg-ppp? file and use it in chat-ppp? | |
13 | # You only have to add it's name into DATAFORCHAT variable | |
14 | # Note, that chat-ppp file is now parsed by shell, so you have to escape | |
15 | # with "\" all shell special characters like \$;:)(& etc. | |
a6c22d3d | 16 | |
7742e157 AF |
17 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
18 | ||
19 | # ifup-post for PPP is handled through /etc/ppp/ip-up | |
7742e157 | 20 | |
f3002e12 JK |
21 | . /etc/sysconfig/network |
22 | . /etc/rc.d/init.d/functions | |
f67ce454 | 23 | . /lib/rc-scripts/functions.network |
8b3e2b71 | 24 | |
a6c22d3d | 25 | CONFIG=$1 |
7742e157 | 26 | source_config |
de1fc6ce JR |
27 | # set all major variables |
28 | setup_ip_param | |
29 | ||
dd4a755f | 30 | if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then |
5e6dfc29 | 31 | exit |
7742e157 | 32 | fi |
a6c22d3d | 33 | if [ ! -x /usr/sbin/pppd ]; then |
5e6dfc29 JR |
34 | nls "%s does not exist or is not executable" "/usr/sbin/pppd" |
35 | nls "%s for %s exiting" "ifup-ppp" "$DEVICE" | |
36 | logger -p daemon.info -t ifup-ppp \ | |
37 | "$(nls '%s does not exist or is not executable for %s' \ | |
38 | "/usr/sbin/pppd" "$DEVICE")" | |
39 | exit 1 | |
a6c22d3d | 40 | fi |
3ed6009f | 41 | |
34c624e7 | 42 | # modprobe ppp modules (udev case) |
170103c8 | 43 | [ ! -e /dev/ppp ] && modprobe -s char-major-108 |
de1fc6ce | 44 | |
7742e157 | 45 | opts="lock" |
a6c22d3d | 46 | |
5e6dfc29 JR |
47 | if [ -z "${REPORTFILE}" ] ; then |
48 | REPORTFILE=/dev/null | |
a6c22d3d AM |
49 | fi |
50 | ||
c3bd5d9f | 51 | if [ -n "${PPPOE_DEV}" ]; then |
5e6dfc29 | 52 | if is_yes "${PPPOE_KERNEL}"; then |
170103c8 | 53 | modprobe -s pppoe |
5e6dfc29 JR |
54 | MODEMMODE="plugin rp-pppoe.so" |
55 | MODEMPORT="${PPPOE_DEV}" | |
56 | else | |
57 | MODEMMODE="pty" | |
58 | MODEMPORT="pppoe -I ${PPPOE_DEV} ${PPPOE_OPT}" | |
59 | fi | |
995264bd | 60 | elif is_yes "${PPPOA_EAGLE}"; then |
5e6dfc29 JR |
61 | EAGLECTRL="/usr/sbin/adictrl" |
62 | if [ ! -x $EAGLECTRL ]; then | |
63 | EAGLECTRL="/usr/sbin/eaglectrl" | |
64 | fi | |
65 | if [ ! -x $EAGLECTRL ]; then | |
66 | nls "%s does not exist or is not executable" "$EAGLECTRL" | |
67 | nls "%s for %s exiting" "ifup-ppp" "$DEVICE" | |
68 | exit 1 | |
69 | fi | |
70 | $EAGLECTRL -w | |
71 | PPPOA_IFACE=$( $EAGLECTRL -i 2>/dev/null) | |
72 | if [ -z "$PPPOA_IFACE" ]; then | |
73 | PPPOA_IFACE="(unknown)" | |
74 | else | |
75 | ip link set "$PPPOA_IFACE" up | |
76 | fi | |
86b5dc44 | 77 | MODEMMODE="pty" |
5e6dfc29 JR |
78 | MODEMPORT="pppoa -I ${PPPOA_IFACE} ${PPPOA_OPT}" |
79 | elif is_yes "${PPPOA_SPEEDTOUCH}"; then | |
80 | if is_yes "${PPPOA_KERNEL}"; then | |
170103c8 | 81 | modprobe -s speedtch |
82 | modprobe -s pppoatm | |
1edbaefa | 83 | if [ -n "${PPPOA_FIRMWARE}" ]; then |
84 | modem_run -k -s -f "${PPPOA_FIRMWARE}" | |
85 | fi | |
5e6dfc29 JR |
86 | MODEMMODE="plugin pppoatm.so" |
87 | MODEMPORT="${PPPOA_VPI}.${PPPOA_VCI}" | |
88 | else | |
89 | modem_run -s -f "${PPPOA_FIRMWARE}" | |
90 | MODEMMODE="pty" | |
91 | MODEMPORT="pppoa3 -v1 -c -vpi ${PPPOA_VPI} -vci ${PPPOA_VCI} ${PPPOA_OPT}" | |
92 | fi | |
7ddff09a | 93 | elif is_yes "${PPPOA}"; then |
4db3dc33 AM |
94 | MODEMMODE="plugin pppoatm.so" |
95 | MODEMPORT="${PPPOA_VPI}.${PPPOA_VCI}" | |
c3bd5d9f | 96 | else |
7dbcc468 ER |
97 | |
98 | if [ -n "$MODEMPORT" -a ! -c "$MODEMPORT" ]; then | |
99 | echo >&2 "MODEMPORT=$MODEMPORT is not a character device!" | |
100 | exit 1 | |
101 | fi | |
102 | ||
5e6dfc29 JR |
103 | if is_no "${DIRECT_CONNECT}" || [ -z "${DIRECT_CONNECT}" ]; then |
104 | PEERCONF=/etc/ppp/peers/${DEVNAME} | |
105 | if [ ! -f ${PEERCONF} ]; then | |
106 | if [ -z "${WVDIALSECT}" ]; then | |
107 | # XXX: REPORTFILE support is problematic here --misiek | |
108 | [ -f "${CHATSCRIPT}" ] || CHATSCRIPT=/etc/sysconfig/interfaces/data/chat-${PARENTDEVNAME} | |
109 | if [ ! -f "${CHATSCRIPT}" ]; then | |
b05fe174 | 110 | nls '%s does not exist, perhaps set $CHATSCRIPT' "${CHATSCRIPT}" |
5e6dfc29 JR |
111 | nls 'ifup-ppp for %s exiting' "${DEVNAME}" |
112 | logger -p daemon.info -t ifup-ppp \ | |
113 | "$(nls '%s does not exist for %s' "${CHATSCRIPT}" "${DEVICE}")" | |
114 | exit 1 | |
115 | fi | |
116 | fi | |
117 | logger -s -p daemon.notice -t ifup-ppp "$(nls 'Setting up a new %s config file' "${PEERCONF}")" | |
118 | if [ -f /etc/ppp/peers/${DEVICE} ]; then | |
119 | cp -f /etc/ppp/peers/${DEVICE} ${PEERCONF} | |
120 | else | |
121 | touch ${PEERCONF} | |
122 | fi | |
123 | if [ "${WVDIALSECT}" ]; then | |
124 | echo "connect \"/usr/bin/wvdial --chat ${WVDIALSECT} --config /etc/wvdial.conf >> ${REPORTFILE} 2>&1 \"" >> ${PEERCONF} | |
125 | else | |
126 | if is_yes "${DEBUG}"; then | |
127 | chatdbg="-v" | |
128 | fi | |
129 | if [ -n "${DATAFORCHAT}" ]; then | |
130 | chatreadenv=-E | |
131 | fi | |
132 | echo "connect \"/usr/sbin/chat $chatreadenv -f ${CHATSCRIPT} -r ${REPORTFILE} ${chatdbg}\"" >> ${PEERCONF} | |
133 | fi | |
dec1e742 | 134 | fi |
5e6dfc29 | 135 | opts="$opts call ${DEVNAME}" |
a6c22d3d | 136 | fi |
a6c22d3d AM |
137 | fi |
138 | ||
44a23ed0 | 139 | if [ -z "$MODEMPORT" ]; then |
06997924 PG |
140 | # Last try: |
141 | if [ "${PPPOA_VPI}" -a "${PPPOA_VCI}" ]; then | |
142 | MODEMPORT=${PPPOA_VPI}.${PPPOA_VCI} | |
143 | else | |
144 | echo >&2 "Missing modemport!" | |
145 | exit 1 | |
146 | fi | |
44a23ed0 ER |
147 | fi |
148 | ||
a6c22d3d | 149 | if [ -z "$HOLDOFF" ]; then |
5e6dfc29 | 150 | HOLDOFF=30 |
a6c22d3d | 151 | fi |
dd4a755f | 152 | if is_yes "${PERSIST}"; then |
5e6dfc29 JR |
153 | if [ -z "${MAXFAIL}" ]; then |
154 | MAXFAIL="0" | |
155 | fi | |
156 | opts="$opts persist holdoff $HOLDOFF maxfail $MAXFAIL" | |
7742e157 | 157 | fi |
dd4a755f | 158 | if is_yes "${DEMAND}"; then |
5e6dfc29 JR |
159 | if [ -z "${IDLE}" ]; then |
160 | IDLE="0" | |
161 | fi | |
162 | opts="$opts demand ktune idle ${IDLE}" | |
a6c22d3d AM |
163 | fi |
164 | if ! is_no "${HARDFLOWCTL}"; then | |
5e6dfc29 | 165 | opts="$opts crtscts" |
7742e157 | 166 | fi |
a6c22d3d | 167 | if is_yes "${MODEMCTL}"; then |
5e6dfc29 | 168 | opts="$opts modem" |
7742e157 | 169 | fi |
5fc3f72d SP |
170 | if is_yes "${SYNC}"; then |
171 | opts="$opts sync" | |
172 | fi | |
dd4a755f | 173 | if is_yes "${ESCAPECHARS}"; then |
5e6dfc29 | 174 | opts="$opts asyncmap FFFFFFFF" |
a6c22d3d | 175 | else |
5e6dfc29 | 176 | opts="$opts asyncmap 00000000" |
7742e157 | 177 | fi |
40e44c36 | 178 | if is_yes "${DEFROUTE}"; then |
5e6dfc29 JR |
179 | # pppd will no longer delete an existing default route |
180 | # so we have to help it out a little here. | |
181 | ip route del 0/0 > /dev/null 2>&1 | |
182 | opts="$opts defaultroute" | |
40e44c36 | 183 | elif ! is_no "${DEFROUTE}"; then |
5e6dfc29 | 184 | opts="$opts defaultroute" |
7742e157 | 185 | fi |
a6c22d3d | 186 | if ! is_no "${PEERDNS}"; then |
5e6dfc29 | 187 | opts="$opts usepeerdns" |
de1fc6ce | 188 | fi |
7742e157 | 189 | if [ -n "${MRU}" ] ; then |
5e6dfc29 | 190 | opts="$opts mru ${MRU}" |
7742e157 AF |
191 | fi |
192 | if [ -n "${MTU}" ] ; then | |
5e6dfc29 | 193 | opts="$opts mtu ${MTU}" |
7742e157 | 194 | fi |
de1fc6ce | 195 | if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}${REMIP}" ] ; then |
5e6dfc29 JR |
196 | # if either IP address is set, the following will work. |
197 | opts="$opts ${IP4ADDR}:${REMIP}" | |
de1fc6ce | 198 | fi |
a6c22d3d | 199 | if is_yes "$IPV6_NETWORKING"; then |
5e6dfc29 JR |
200 | if is_yes "$IPV6_PPP"; then |
201 | if [ -n "${IP6ADDR}${REMIP6}" ] ; then | |
202 | opts="$opts ipv6 ${IP6ADDR},${REMIP6}" | |
203 | elif is_yes "$IPV6_CP_USEV4"; then | |
204 | opts="$opts ipv6cp-use-ipaddr" | |
205 | elif is_yes "$IPV6_CP_PERSISTENT"; then | |
206 | opts="$opts ipv6cp-use-persistent" | |
207 | fi | |
208 | elif is_no "$IPV6_PPP"; then | |
209 | opts="$opts noipv6" | |
de1fc6ce | 210 | fi |
a6c22d3d | 211 | elif is_no "$IPV6_NETWORKING"; then |
5e6dfc29 | 212 | opts="$opts noipv6" |
a6c22d3d AM |
213 | fi |
214 | if is_yes "${IPX_PPP}"; then | |
5e6dfc29 JR |
215 | opts="$opts ipx" |
216 | if [ -n "${IPX_PPP_NETWORK}" ]; then | |
217 | opts="$opts ipx-network ${IPX_PPP_NETWORK}" | |
218 | fi | |
219 | if [ -n "${IPX_PPP_NODE}" ]; then | |
220 | opts="$opts ipx-node ${IPX_PPP_NODE}" | |
221 | fi | |
222 | if [ -n "${IPX_PPP_ROUTING}" ]; then | |
223 | opts="$opts ipx-routing ${IPX_PPP_ROUTING}" | |
224 | fi | |
7742e157 | 225 | fi |
c3bd5d9f | 226 | |
7742e157 | 227 | if [ -n "${PAPNAME}" ] ; then |
5e6dfc29 | 228 | opts="$opts user ${PAPNAME}" |
7742e157 | 229 | fi |
200ca1e9 | 230 | if [ -n "${REMOTENAME}" ] ; then |
5e6dfc29 | 231 | opts="$opts remotename ${REMOTENAME}" |
200ca1e9 | 232 | fi |
dd4a755f | 233 | if is_yes "${DEBUG}"; then |
5e6dfc29 | 234 | opts="$opts debug" |
7742e157 | 235 | fi |
a6c22d3d | 236 | if is_yes "${AUTH}"; then |
5e6dfc29 | 237 | opts="$opts auth" |
a6c22d3d | 238 | elif is_no "${AUTH}"; then |
5e6dfc29 | 239 | opts="$opts noauth" |
7742e157 | 240 | fi |
f42fe46b | 241 | if is_yes "$PLUGIN_IFCFG_PASSWORD" && [ -n "$PASSWORD" ]; then |
5e6dfc29 JR |
242 | if [ -f "$CONFIG" ]; then |
243 | ifcfg_password_config="$CONFIG" | |
244 | else | |
245 | ifcfg_password_config="/etc/sysconfig/interfaces/$CONFIG" | |
246 | fi | |
247 | opts="$opts plugin ifcfg-password.so ifcfg $ifcfg_password_config" | |
8175323a | 248 | fi |
7742e157 | 249 | |
c3bd5d9f | 250 | if ! is_no "${UNIT}"; then |
5e6dfc29 JR |
251 | UNIT=$(echo "${DEVICE}" | awk ' { gsub(/ppp/,NUL); print $0} ') |
252 | opts="$opts unit ${UNIT}" | |
c3bd5d9f AM |
253 | fi |
254 | ||
c4e87d18 AM |
255 | MODEM="${MODEMPORT}"; export MODEM |
256 | ||
a6c22d3d | 257 | (logger -p daemon.info -t ifup-ppp \ |
5e6dfc29 | 258 | "$(nls 'pppd started for %s on device %s at speed %s' "$DEVICE" \ |
74a7f2e4 | 259 | "$MODEMPORT" "${LINESPEED:-(unspecified)} on unit ${UNIT}")" &)& |
de1fc6ce | 260 | |
dec1e742 | 261 | if [ -n "${DATAFORCHAT}" ]; then |
5e6dfc29 | 262 | export $DATAFORCHAT |
dec1e742 | 263 | fi |
c3bd5d9f | 264 | /usr/sbin/pppd $opts ${MODEMMODE} "${MODEMPORT}" ${LINESPEED} \ |
5e6dfc29 JR |
265 | ipparam ${DEVNAME} linkname ${DEVNAME} \ |
266 | ${PPPOPTIONS} |