4 # ifup-ppp script for pppd-2.3.5 (with persist & demand options) ver 0.2
5 # Grzegorz Stanislawski <stangrze@open.net.pl>
7 # - since persist option is included to pppd it's no need to do werid loops
8 # ifup-ppp script. This also makes your logfile grow slower when Your link
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.
17 PATH=/sbin:/usr/sbin:/bin:/usr/bin
19 # ifup-post for PPP is handled through /etc/ppp/ip-up
21 . /etc/sysconfig/network
22 . /etc/rc.d/init.d/functions
23 . /lib/rc-scripts/functions.network
27 # set all major variables
30 if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then
33 if [ ! -x /usr/sbin/pppd ]; then
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")"
42 # modprobe ppp modules (udev case)
43 [ ! -e /dev/ppp ] && modprobe -s char-major-108
47 if [ -z "${REPORTFILE}" ] ; then
51 if [ -n "${PPPOE_DEV}" ]; then
52 if is_yes "${PPPOE_KERNEL}"; then
54 MODEMMODE="plugin rp-pppoe.so"
55 MODEMPORT="${PPPOE_DEV}"
58 MODEMPORT="pppoe -I ${PPPOE_DEV} ${PPPOE_OPT}"
60 elif is_yes "${PPPOA_EAGLE}"; then
61 EAGLECTRL="/usr/sbin/adictrl"
62 if [ ! -x $EAGLECTRL ]; then
63 EAGLECTRL="/usr/sbin/eaglectrl"
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"
71 PPPOA_IFACE=$( $EAGLECTRL -i 2>/dev/null)
72 if [ -z "$PPPOA_IFACE" ]; then
73 PPPOA_IFACE="(unknown)"
75 ip link set "$PPPOA_IFACE" up
78 MODEMPORT="pppoa -I ${PPPOA_IFACE} ${PPPOA_OPT}"
79 elif is_yes "${PPPOA_SPEEDTOUCH}"; then
80 if is_yes "${PPPOA_KERNEL}"; then
83 if [ -n "${PPPOA_FIRMWARE}" ]; then
84 modem_run -k -s -f "${PPPOA_FIRMWARE}"
86 MODEMMODE="plugin pppoatm.so"
87 MODEMPORT="${PPPOA_VPI}.${PPPOA_VCI}"
89 modem_run -s -f "${PPPOA_FIRMWARE}"
91 MODEMPORT="pppoa3 -v1 -c -vpi ${PPPOA_VPI} -vci ${PPPOA_VCI} ${PPPOA_OPT}"
93 elif is_yes "${PPPOA}"; then
94 MODEMMODE="plugin pppoatm.so"
95 MODEMPORT="${PPPOA_VPI}.${PPPOA_VCI}"
98 if [ -n "$MODEMPORT" -a ! -c "$MODEMPORT" ]; then
99 echo >&2 "MODEMPORT=$MODEMPORT is not a character device!"
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
110 nls '%s does not exist, perhaps set $CHATSCRIPT' "${CHATSCRIPT}"
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}")"
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}
123 if [ "${WVDIALSECT}" ]; then
124 echo "connect \"/usr/bin/wvdial --chat ${WVDIALSECT} --config /etc/wvdial.conf >> ${REPORTFILE} 2>&1 \"" >> ${PEERCONF}
126 if is_yes "${DEBUG}"; then
129 if [ -n "${DATAFORCHAT}" ]; then
132 echo "connect \"/usr/sbin/chat $chatreadenv -f ${CHATSCRIPT} -r ${REPORTFILE} ${chatdbg}\"" >> ${PEERCONF}
135 opts="$opts call ${DEVNAME}"
139 if [ -z "$MODEMPORT" ]; then
141 if [ "${PPPOA_VPI}" -a "${PPPOA_VCI}" ]; then
142 MODEMPORT=${PPPOA_VPI}.${PPPOA_VCI}
144 echo >&2 "Missing modemport!"
149 if [ -z "$HOLDOFF" ]; then
152 if is_yes "${PERSIST}"; then
153 if [ -z "${MAXFAIL}" ]; then
156 opts="$opts persist holdoff $HOLDOFF maxfail $MAXFAIL"
158 if is_yes "${DEMAND}"; then
159 if [ -z "${IDLE}" ]; then
162 opts="$opts demand ktune idle ${IDLE}"
164 if ! is_no "${HARDFLOWCTL}"; then
167 if is_yes "${MODEMCTL}"; then
170 if is_yes "${SYNC}"; then
173 if is_yes "${ESCAPECHARS}"; then
174 opts="$opts asyncmap FFFFFFFF"
176 opts="$opts asyncmap 00000000"
178 if is_yes "${DEFROUTE}"; then
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"
183 elif ! is_no "${DEFROUTE}"; then
184 opts="$opts defaultroute"
186 if ! is_no "${PEERDNS}"; then
187 opts="$opts usepeerdns"
189 if [ -n "${MRU}" ] ; then
190 opts="$opts mru ${MRU}"
192 if [ -n "${MTU}" ] ; then
193 opts="$opts mtu ${MTU}"
195 if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}${REMIP}" ] ; then
196 # if either IP address is set, the following will work.
197 opts="$opts ${IP4ADDR}:${REMIP}"
199 if is_yes "$IPV6_NETWORKING"; then
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"
208 elif is_no "$IPV6_PPP"; then
211 elif is_no "$IPV6_NETWORKING"; then
214 if is_yes "${IPX_PPP}"; then
216 if [ -n "${IPX_PPP_NETWORK}" ]; then
217 opts="$opts ipx-network ${IPX_PPP_NETWORK}"
219 if [ -n "${IPX_PPP_NODE}" ]; then
220 opts="$opts ipx-node ${IPX_PPP_NODE}"
222 if [ -n "${IPX_PPP_ROUTING}" ]; then
223 opts="$opts ipx-routing ${IPX_PPP_ROUTING}"
227 if [ -n "${PAPNAME}" ] ; then
228 opts="$opts user ${PAPNAME}"
230 if [ -n "${REMOTENAME}" ] ; then
231 opts="$opts remotename ${REMOTENAME}"
233 if is_yes "${DEBUG}"; then
236 if is_yes "${AUTH}"; then
238 elif is_no "${AUTH}"; then
241 if is_yes "$PLUGIN_IFCFG_PASSWORD" && [ -n "$PASSWORD" ]; then
242 if [ -f "$CONFIG" ]; then
243 ifcfg_password_config="$CONFIG"
245 ifcfg_password_config="/etc/sysconfig/interfaces/$CONFIG"
247 opts="$opts plugin ifcfg-password.so ifcfg $ifcfg_password_config"
250 if ! is_no "${UNIT}"; then
251 UNIT=$(echo "${DEVICE}" | awk ' { gsub(/ppp/,NUL); print $0} ')
252 opts="$opts unit ${UNIT}"
255 MODEM="${MODEMPORT}"; export MODEM
257 (logger -p daemon.info -t ifup-ppp \
258 "$(nls 'pppd started for %s on device %s at speed %s' "$DEVICE" \
259 "$MODEMPORT" "${LINESPEED:-(unspecified)} on unit ${UNIT}")" &)&
261 if [ -n "${DATAFORCHAT}" ]; then
264 /usr/sbin/pppd $opts ${MODEMMODE} "${MODEMPORT}" ${LINESPEED} \
265 ipparam ${DEVNAME} linkname ${DEVNAME} \