]> git.pld-linux.org Git - projects/rc-scripts.git/blame - sysconfig/network-scripts/ifup-ppp
- functions.network back in old place
[projects/rc-scripts.git] / sysconfig / network-scripts / ifup-ppp
CommitLineData
12de71be 1#!/bin/sh
b0443108 2#
baa6b418 3# $Id: ifup-ppp,v 1.19 2002/05/11 09:50:53 misiek Exp $
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.
17
18PATH=/sbin:/usr/sbin:/bin:/usr/bin
19
20# ifup-post for PPP is handled through /etc/ppp/ip-up
7742e157
AF
21
22CONFIG=$1
f3002e12
JK
23. /etc/sysconfig/network
24. /etc/rc.d/init.d/functions
baa6b418 25. /etc/sysconfig/network-scripts/functions.network
8b3e2b71 26
7742e157 27source_config
de1fc6ce
JR
28
29# set all major variables
30setup_ip_param
31
7b4e96e8
AM
32[ -z "$HOLDOFF" ] && HOLDOFF=30
33
dd4a755f 34if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then
7742e157
AF
35 exit
36fi
37[ -x /usr/sbin/pppd ] || {
95a724b3
JR
38 nls "%s does not exist or is not executable" "/usr/sbin/pppd"
39 nls "%s for %s exiting" "ifup-ppp" "$DEVICE"
7742e157 40 logger -p daemon.info -t ifup-ppp \
95a724b3 41 "$(nls '%s does not exist or is not executable for %s' "/usr/sbin/pppd" "$DEVICE")"
7742e157
AF
42 exit 1
43}
3ed6009f 44
de1fc6ce
JR
45# modprobe ppp in case of kernel with devfs
46# (/dev/ppp is missing and ppp fails without this) --misiek
47if [ -c /dev/.devfsd ]; then
48 modprobe -s -k char-major-108
49fi
50
7742e157 51opts="lock"
dd4a755f 52if is_yes "${PERSIST}"; then
3ed6009f 53 if [ -z "${MAXFAIL}" ]; then
54 MAXFAIL="0"
55 fi
7b4e96e8 56 opts="$opts persist holdoff $HOLDOFF maxfail $MAXFAIL"
7742e157 57fi
dd4a755f 58if is_yes "${DEMAND}"; then
3ed6009f 59 if [ -z "${IDLE}" ]; then
60 IDLE="0"
61 fi
62 opts="$opts demand idle ${IDLE}"
7742e157 63fi
dd4a755f 64if is_yes "${HARDFLOWCTL}"; then
7742e157
AF
65 opts="$opts modem crtscts"
66fi
dd4a755f 67if is_yes "${ESCAPECHARS}"; then
d29c401a
AM
68 opts="$opts asyncmap FFFFFFFF"
69elif [ "${ESCAPECHARS}" = no ] ; then
7742e157
AF
70 opts="$opts asyncmap 00000000"
71fi
dd4a755f 72if is_yes "${DEFROUTE}" = yes; then
de1fc6ce
JR
73 # pppd will no longer delete an existing default route
74 # so we have to help it out a little here.
75 ip route del 0/0 > /dev/null 2>&1
7742e157
AF
76 opts="$opts defaultroute"
77fi
de1fc6ce
JR
78if is_yes "${PEERDNS}"; then
79 opts="$opts usepeerdns"
80fi
7742e157
AF
81if [ -n "${MRU}" ] ; then
82 opts="$opts mru ${MRU}"
83fi
84if [ -n "${MTU}" ] ; then
85 opts="$opts mtu ${MTU}"
86fi
de1fc6ce 87if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}${REMIP}" ] ; then
7742e157 88 # if either IP address is set, the following will work.
de1fc6ce
JR
89 opts="$opts ${IP4ADDR}:${REMIP}"
90fi
91if is_yes "$IPV6_NETWORKING" && is_yes "$IPV6_PPP"; then
92 if [ -n "${IP6ADDR}${REMIP6}" ] ; then
93 opts="$opts ipv6 ${IP6ADDR},${REMIP6}"
94 elif is_yes "$IPV6_CP_USEV4"; then
95 opts="$opts ipv6cp-use-ipaddr"
96 elif is_yes "$IPV6_CP_PERSISTENT"; then
97 opts="$opts ipv6cp-use-persistent"
98 fi
99else
100 opts="$opts noipv6"
7742e157
AF
101fi
102if [ -n "${PAPNAME}" ] ; then
103 opts="$opts name ${PAPNAME}"
104fi
200ca1e9
JK
105if [ -n "${REMOTENAME}" ] ; then
106 opts="$opts remotename ${REMOTENAME}"
107fi
4024df22 108if [ -n "${USER}" ] ; then
109 opts="$opts user ${USER}"
110fi
dd4a755f 111if is_yes "${DEBUG}"; then
7742e157
AF
112 opts="$opts debug"
113 chatdbg="-v"
114fi
03f9cfee
JR
115case "${AUTH}" in
116 yes) opts="$opts auth"
117 ;;
118 no) opts="$opts noauth"
119 ;;
120 *)
121 ;;
122esac
7742e157
AF
123if [ -n "${REPORTFILE}" ] ; then
124 chatrpt="-r ${REPORTFILE}"
125fi
3ed6009f 126
7742e157
AF
127(logger -p daemon.info -t ifup-ppp \
128 "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
7742e157
AF
129if [ -n "${CHATSCRIPT}" ] ; then
130 export chatdbg chatrpt CHATSCRIPT
0d07161b 131 if [ -n "${DATAFORCHAT}" ]; then
de1fc6ce 132 export $DATAFORCHAT
b4df11d7 133 fi
200ca1e9 134 /usr/sbin/pppd $opts $MODEMPORT $LINESPEED \
de1fc6ce
JR
135 connect 'eval /usr/sbin/chat -E $chatdbg $chatrpt \
136 $(grep -v ^# ${CHATSCRIPT})' \
200ca1e9
JK
137 linkname "${DEVICE}" ipparam "${CONFIG}" \
138 ${PPPOPTIONS}
7742e157 139else
200ca1e9
JK
140 /usr/sbin/pppd $opts $MODEMPORT $LINESPEED \
141 linkname "${DEVICE}" ipparam "${CONFIG}" \
142 ${PPPOPTIONS}
7742e157 143fi
7742e157 144
de1fc6ce
JR
145
146# This must be last line !
147# vi:syntax=sh:tw=78:ts=8:sw=4
This page took 0.055719 seconds and 4 git commands to generate.