]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
b0443108 | 2 | # |
b4df11d7 | 3 | # $Id: ifup-ppp,v 1.14 2001/03/22 21:50:36 qboosh 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 | |
8b3e2b71 | 25 | . /etc/sysconfig/network-scripts/.functions |
26 | ||
7742e157 | 27 | source_config |
7b4e96e8 AM |
28 | [ -z "$HOLDOFF" ] && HOLDOFF=30 |
29 | ||
dd4a755f | 30 | if [ "$2" = "boot" ] && is_no "${ONBOOT}"; then |
7742e157 AF |
31 | exit |
32 | fi | |
33 | [ -x /usr/sbin/pppd ] || { | |
34 | echo "/usr/sbin/pppd does not exist or is not executable" | |
35 | echo "ifup-ppp for $DEVICE exiting" | |
36 | logger -p daemon.info -t ifup-ppp \ | |
37 | "/usr/sbin/pppd does not exist or is not executable for $DEVICE" | |
38 | exit 1 | |
39 | } | |
3ed6009f | 40 | |
7742e157 | 41 | opts="lock" |
dd4a755f | 42 | if is_yes "${PERSIST}"; then |
3ed6009f | 43 | if [ -z "${MAXFAIL}" ]; then |
44 | MAXFAIL="0" | |
45 | fi | |
7b4e96e8 | 46 | opts="$opts persist holdoff $HOLDOFF maxfail $MAXFAIL" |
7742e157 | 47 | fi |
dd4a755f | 48 | if is_yes "${DEMAND}"; then |
3ed6009f | 49 | if [ -z "${IDLE}" ]; then |
50 | IDLE="0" | |
51 | fi | |
52 | opts="$opts demand idle ${IDLE}" | |
7742e157 | 53 | fi |
dd4a755f | 54 | if is_yes "${HARDFLOWCTL}"; then |
7742e157 AF |
55 | opts="$opts modem crtscts" |
56 | fi | |
dd4a755f | 57 | if is_yes "${ESCAPECHARS}"; then |
d29c401a AM |
58 | opts="$opts asyncmap FFFFFFFF" |
59 | elif [ "${ESCAPECHARS}" = no ] ; then | |
7742e157 AF |
60 | opts="$opts asyncmap 00000000" |
61 | fi | |
dd4a755f | 62 | if is_yes "${DEFROUTE}" = yes; then |
7742e157 AF |
63 | opts="$opts defaultroute" |
64 | fi | |
65 | if [ -n "${MRU}" ] ; then | |
66 | opts="$opts mru ${MRU}" | |
67 | fi | |
68 | if [ -n "${MTU}" ] ; then | |
69 | opts="$opts mtu ${MTU}" | |
70 | fi | |
71 | if [ -n "${IPADDR}${REMIP}" ] ; then | |
72 | # if either IP address is set, the following will work. | |
73 | opts="$opts ${IPADDR}:${REMIP}" | |
74 | fi | |
75 | if [ -n "${PAPNAME}" ] ; then | |
76 | opts="$opts name ${PAPNAME}" | |
77 | fi | |
200ca1e9 JK |
78 | if [ -n "${REMOTENAME}" ] ; then |
79 | opts="$opts remotename ${REMOTENAME}" | |
80 | fi | |
dd4a755f | 81 | if is_yes "${DEBUG}"; then |
7742e157 AF |
82 | opts="$opts debug" |
83 | chatdbg="-v" | |
84 | fi | |
03f9cfee JR |
85 | case "${AUTH}" in |
86 | yes) opts="$opts auth" | |
87 | ;; | |
88 | no) opts="$opts noauth" | |
89 | ;; | |
90 | *) | |
91 | ;; | |
92 | esac | |
7742e157 AF |
93 | if [ -n "${REPORTFILE}" ] ; then |
94 | chatrpt="-r ${REPORTFILE}" | |
95 | fi | |
3ed6009f | 96 | |
7742e157 AF |
97 | (logger -p daemon.info -t ifup-ppp \ |
98 | "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)& | |
7742e157 AF |
99 | if [ -n "${CHATSCRIPT}" ] ; then |
100 | export chatdbg chatrpt CHATSCRIPT | |
b4df11d7 JB |
101 | if [ -n "${DATAFORCHAT}" ] ; then |
102 | export $DATAFORCHAT | |
103 | fi | |
200ca1e9 | 104 | /usr/sbin/pppd $opts $MODEMPORT $LINESPEED \ |
12de71be | 105 | connect 'eval /usr/sbin/chat $chatdbg $chatrpt \ |
106 | `grep -v ^# ${CHATSCRIPT}`' \ | |
200ca1e9 JK |
107 | linkname "${DEVICE}" ipparam "${CONFIG}" \ |
108 | ${PPPOPTIONS} | |
7742e157 | 109 | else |
200ca1e9 JK |
110 | /usr/sbin/pppd $opts $MODEMPORT $LINESPEED \ |
111 | linkname "${DEVICE}" ipparam "${CONFIG}" \ | |
112 | ${PPPOPTIONS} | |
7742e157 | 113 | fi |
7742e157 | 114 |