5 # ifup-ppp script for pppd-2.3.5 (with persist & demand options) ver 0.2
6 # Grzegorz Stanislawski <stangrze@open.net.pl>
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
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.
18 PATH=/sbin:/usr/sbin:/bin:/usr/bin
20 # ifup-post for PPP is handled through /etc/ppp/ip-up
22 . /etc/sysconfig/network
23 . /etc/rc.d/init.d/functions
24 . /lib/rc-scripts/functions.network
28 # set all major variables
31 if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then
34 if [ ! -x /usr/sbin/pppd ]; then
35 nls "%s does not exist or is not executable" "/usr/sbin/pppd"
36 nls "%s for %s exiting" "ifup-ppp" "$DEVICE"
37 logger -p daemon.info -t ifup-ppp \
38 "$(nls '%s does not exist or is not executable for %s' \
39 "/usr/sbin/pppd" "$DEVICE")"
43 # modprobe ppp modules (udev case)
44 [ ! -e /dev/ppp ] && modprobe -s char-major-108
48 if [ -z "${REPORTFILE}" ] ; then
52 if [ -n "${PPPOE_DEV}" ]; then
53 if is_yes "${PPPOE_KERNEL}"; then
55 MODEMMODE="plugin rp-pppoe.so"
56 MODEMPORT="${PPPOE_DEV}"
59 MODEMPORT="pppoe -I ${PPPOE_DEV} ${PPPOE_OPT}"
61 elif is_yes "${PPPOA_EAGLE}"; then
62 EAGLECTRL="/usr/sbin/adictrl"
63 if [ ! -x $EAGLECTRL ]; then
64 EAGLECTRL="/usr/sbin/eaglectrl"
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"
72 PPPOA_IFACE=$( $EAGLECTRL -i 2>/dev/null)
73 if [ -z "$PPPOA_IFACE" ]; then
74 PPPOA_IFACE="(unknown)"
76 ip link set "$PPPOA_IFACE" up
79 MODEMPORT="pppoa -I ${PPPOA_IFACE} ${PPPOA_OPT}"
80 elif is_yes "${PPPOA_SPEEDTOUCH}"; then
81 if is_yes "${PPPOA_KERNEL}"; then
84 if [ -n "${PPPOA_FIRMWARE}" ]; then
85 modem_run -k -s -f "${PPPOA_FIRMWARE}"
87 MODEMMODE="plugin pppoatm.so"
88 MODEMPORT="${PPPOA_VPI}.${PPPOA_VCI}"
90 modem_run -s -f "${PPPOA_FIRMWARE}"
92 MODEMPORT="pppoa3 -v1 -c -vpi ${PPPOA_VPI} -vci ${PPPOA_VCI} ${PPPOA_OPT}"
94 elif is_yes "${PPPOA}"; then
95 MODEMMODE="plugin pppoatm.so"
96 MODEMPORT="${PPPOA_VPI}.${PPPOA_VCI}"
99 if [ -n "$MODEMPORT" -a ! -c "$MODEMPORT" ]; then
100 echo >&2 "MODEMPORT=$MODEMPORT is not a character device!"
104 if is_no "${DIRECT_CONNECT}" || [ -z "${DIRECT_CONNECT}" ]; then
105 PEERCONF=/etc/ppp/peers/${DEVNAME}
106 if [ ! -f ${PEERCONF} ]; then
107 if [ -z "${WVDIALSECT}" ]; then
108 # XXX: REPORTFILE support is problematic here --misiek
109 [ -f "${CHATSCRIPT}" ] || CHATSCRIPT=/etc/sysconfig/interfaces/data/chat-${PARENTDEVNAME}
110 if [ ! -f "${CHATSCRIPT}" ]; then
111 nls '%s does not exist, perhaps set $CHATSCRIPT' "${CHATSCRIPT}"
112 nls 'ifup-ppp for %s exiting' "${DEVNAME}"
113 logger -p daemon.info -t ifup-ppp \
114 "$(nls '%s does not exist for %s' "${CHATSCRIPT}" "${DEVICE}")"
118 logger -s -p daemon.notice -t ifup-ppp "$(nls 'Setting up a new %s config file' "${PEERCONF}")"
119 if [ -f /etc/ppp/peers/${DEVICE} ]; then
120 cp -f /etc/ppp/peers/${DEVICE} ${PEERCONF}
124 if [ "${WVDIALSECT}" ]; then
125 echo "connect \"/usr/bin/wvdial --chat ${WVDIALSECT} --config /etc/wvdial.conf >> ${REPORTFILE} 2>&1 \"" >> ${PEERCONF}
127 if is_yes "${DEBUG}"; then
130 if [ -n "${DATAFORCHAT}" ]; then
133 echo "connect \"/usr/sbin/chat $chatreadenv -f ${CHATSCRIPT} -r ${REPORTFILE} ${chatdbg}\"" >> ${PEERCONF}
136 opts="$opts call ${DEVNAME}"
140 if [ -z "$MODEMPORT" ]; then
142 if [ "${PPPOA_VPI}" -a "${PPPOA_VCI}" ]; then
143 MODEMPORT=${PPPOA_VPI}.${PPPOA_VCI}
145 echo >&2 "Missing modemport!"
150 if [ -z "$HOLDOFF" ]; then
153 if is_yes "${PERSIST}"; then
154 if [ -z "${MAXFAIL}" ]; then
157 opts="$opts persist holdoff $HOLDOFF maxfail $MAXFAIL"
159 if is_yes "${DEMAND}"; then
160 if [ -z "${IDLE}" ]; then
163 opts="$opts demand ktune idle ${IDLE}"
165 if ! is_no "${HARDFLOWCTL}"; then
168 if is_yes "${MODEMCTL}"; then
171 if is_yes "${SYNC}"; then
174 if is_yes "${ESCAPECHARS}"; then
175 opts="$opts asyncmap FFFFFFFF"
177 opts="$opts asyncmap 00000000"
179 if is_yes "${DEFROUTE}"; then
180 # pppd will no longer delete an existing default route
181 # so we have to help it out a little here.
182 ip route del 0/0 > /dev/null 2>&1
183 opts="$opts defaultroute"
184 elif ! is_no "${DEFROUTE}"; then
185 opts="$opts defaultroute"
187 if ! is_no "${PEERDNS}"; then
188 opts="$opts usepeerdns"
190 if [ -n "${MRU}" ] ; then
191 opts="$opts mru ${MRU}"
193 if [ -n "${MTU}" ] ; then
194 opts="$opts mtu ${MTU}"
196 if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}${REMIP}" ] ; then
197 # if either IP address is set, the following will work.
198 opts="$opts ${IP4ADDR}:${REMIP}"
200 if is_yes "$IPV6_NETWORKING"; then
201 if is_yes "$IPV6_PPP"; then
202 if [ -n "${IP6ADDR}${REMIP6}" ] ; then
203 opts="$opts ipv6 ${IP6ADDR},${REMIP6}"
204 elif is_yes "$IPV6_CP_USEV4"; then
205 opts="$opts ipv6cp-use-ipaddr"
206 elif is_yes "$IPV6_CP_PERSISTENT"; then
207 opts="$opts ipv6cp-use-persistent"
209 elif is_no "$IPV6_PPP"; then
212 elif is_no "$IPV6_NETWORKING"; then
215 if is_yes "${IPX_PPP}"; then
217 if [ -n "${IPX_PPP_NETWORK}" ]; then
218 opts="$opts ipx-network ${IPX_PPP_NETWORK}"
220 if [ -n "${IPX_PPP_NODE}" ]; then
221 opts="$opts ipx-node ${IPX_PPP_NODE}"
223 if [ -n "${IPX_PPP_ROUTING}" ]; then
224 opts="$opts ipx-routing ${IPX_PPP_ROUTING}"
228 if [ -n "${PAPNAME}" ] ; then
229 opts="$opts user ${PAPNAME}"
231 if [ -n "${REMOTENAME}" ] ; then
232 opts="$opts remotename ${REMOTENAME}"
234 if is_yes "${DEBUG}"; then
237 if is_yes "${AUTH}"; then
239 elif is_no "${AUTH}"; then
242 if is_yes "$PLUGIN_IFCFG_PASSWORD" && [ -n "$PASSWORD" ]; then
243 if [ -f "$CONFIG" ]; then
244 ifcfg_password_config="$CONFIG"
246 ifcfg_password_config="/etc/sysconfig/interfaces/$CONFIG"
248 opts="$opts plugin ifcfg-password.so ifcfg $ifcfg_password_config"
251 if ! is_no "${UNIT}"; then
252 UNIT=$(echo "${DEVICE}" | awk ' { gsub(/ppp/,NUL); print $0} ')
253 opts="$opts unit ${UNIT}"
256 MODEM="${MODEMPORT}"; export MODEM
258 (logger -p daemon.info -t ifup-ppp \
259 "$(nls 'pppd started for %s on device %s at speed %s' "$DEVICE" \
260 "$MODEMPORT" "${LINESPEED:-(unspecified)} on unit ${UNIT}")" &)&
262 if [ -n "${DATAFORCHAT}" ]; then
265 /usr/sbin/pppd $opts ${MODEMMODE} "${MODEMPORT}" ${LINESPEED} \
266 ipparam ${DEVNAME} linkname ${DEVNAME} \