]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
19 | ||
20 | # ifup-post for PPP is handled through /etc/ppp/ip-up | |
7742e157 AF |
21 | |
22 | CONFIG=$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 | 27 | source_config |
de1fc6ce JR |
28 | |
29 | # set all major variables | |
30 | setup_ip_param | |
31 | ||
7b4e96e8 AM |
32 | [ -z "$HOLDOFF" ] && HOLDOFF=30 |
33 | ||
dd4a755f | 34 | if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then |
7742e157 AF |
35 | exit |
36 | fi | |
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 | |
47 | if [ -c /dev/.devfsd ]; then | |
48 | modprobe -s -k char-major-108 | |
49 | fi | |
50 | ||
7742e157 | 51 | opts="lock" |
dd4a755f | 52 | if 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 | 57 | fi |
dd4a755f | 58 | if is_yes "${DEMAND}"; then |
3ed6009f | 59 | if [ -z "${IDLE}" ]; then |
60 | IDLE="0" | |
61 | fi | |
62 | opts="$opts demand idle ${IDLE}" | |
7742e157 | 63 | fi |
dd4a755f | 64 | if is_yes "${HARDFLOWCTL}"; then |
7742e157 AF |
65 | opts="$opts modem crtscts" |
66 | fi | |
dd4a755f | 67 | if is_yes "${ESCAPECHARS}"; then |
d29c401a AM |
68 | opts="$opts asyncmap FFFFFFFF" |
69 | elif [ "${ESCAPECHARS}" = no ] ; then | |
7742e157 AF |
70 | opts="$opts asyncmap 00000000" |
71 | fi | |
dd4a755f | 72 | if 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" |
77 | fi | |
de1fc6ce JR |
78 | if is_yes "${PEERDNS}"; then |
79 | opts="$opts usepeerdns" | |
80 | fi | |
7742e157 AF |
81 | if [ -n "${MRU}" ] ; then |
82 | opts="$opts mru ${MRU}" | |
83 | fi | |
84 | if [ -n "${MTU}" ] ; then | |
85 | opts="$opts mtu ${MTU}" | |
86 | fi | |
de1fc6ce | 87 | if 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}" |
90 | fi | |
91 | if 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 | |
99 | else | |
100 | opts="$opts noipv6" | |
7742e157 AF |
101 | fi |
102 | if [ -n "${PAPNAME}" ] ; then | |
103 | opts="$opts name ${PAPNAME}" | |
104 | fi | |
200ca1e9 JK |
105 | if [ -n "${REMOTENAME}" ] ; then |
106 | opts="$opts remotename ${REMOTENAME}" | |
107 | fi | |
4024df22 | 108 | if [ -n "${USER}" ] ; then |
109 | opts="$opts user ${USER}" | |
110 | fi | |
dd4a755f | 111 | if is_yes "${DEBUG}"; then |
7742e157 AF |
112 | opts="$opts debug" |
113 | chatdbg="-v" | |
114 | fi | |
03f9cfee JR |
115 | case "${AUTH}" in |
116 | yes) opts="$opts auth" | |
117 | ;; | |
118 | no) opts="$opts noauth" | |
119 | ;; | |
120 | *) | |
121 | ;; | |
122 | esac | |
7742e157 AF |
123 | if [ -n "${REPORTFILE}" ] ; then |
124 | chatrpt="-r ${REPORTFILE}" | |
125 | fi | |
3ed6009f | 126 | |
7742e157 AF |
127 | (logger -p daemon.info -t ifup-ppp \ |
128 | "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)& | |
7742e157 AF |
129 | if [ -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 | 139 | else |
200ca1e9 JK |
140 | /usr/sbin/pppd $opts $MODEMPORT $LINESPEED \ |
141 | linkname "${DEVICE}" ipparam "${CONFIG}" \ | |
142 | ${PPPOPTIONS} | |
7742e157 | 143 | fi |
7742e157 | 144 | |
de1fc6ce JR |
145 | |
146 | # This must be last line ! | |
147 | # vi:syntax=sh:tw=78:ts=8:sw=4 |