source: projects/initscripts/tags/initscripts-8.91.0/sysconfig/network-scripts/ifup-ppp @ 2576

Revision 2576, 4.2 KB checked in by daisuke, 13 years ago (diff)

tagging as initscripts-8.91.0

Line 
1#! /bin/bash
2
3. /etc/init.d/functions
4
5cd /etc/sysconfig/network-scripts
6. /etc/sysconfig/network-scripts/network-functions
7
8# ifup-post for PPP is handled through /etc/ppp/ip-up
9if [ "${1}" = daemon ] ; then
10  # we've been called from ppp-watch, so don't invoke it for persistence
11  shift
12else
13  # just in case a full path to the configuration file is passed in
14  CONFIG=${1##*/} # CONFIG=$(basename $1)
15  [ -f "${CONFIG}" ] || CONFIG=ifcfg-${1}
16  source_config
17  # don't start ppp-watch by xDSL
18  if [ "${DEMAND}" != yes -a "$TYPE" != "xDSL" ] ; then
19    # let ppp-watch do the right thing
20    exec /sbin/ppp-watch "${CONFIG##ifcfg-}" "$2"
21  fi
22fi
23
24CONFIG=$1
25[ -f "${CONFIG}" ] || CONFIG=ifcfg-${1}
26source_config
27
28if [ -z "${DISCONNECTTIMEOUT}" ]; then
29  DISCONNECTTIMEOUT=2
30fi
31
32if [ -z "${RETRYTIMEOUT}" ]; then
33  RETRYTIMEOUT=30
34fi
35
36if [ -z "${IDLETIMEOUT}" ]; then
37  IDLETIMEOUT=600
38fi
39
40if [ "${2}" = "boot" -a "${ONBOOT}" = "no" ]; then
41  exit
42fi
43
44[ -x /sbin/pppd -o -x /usr/sbin/pppd ] || {
45  echo $"pppd does not exist or is not executable"
46  echo $"ifup-ppp for ${DEVICE} exiting"
47  logger -p daemon.info -t ifup-ppp \
48    $"pppd does not exist or is not executable for ${DEVICE}"
49  exit 1
50}
51
52# check that xDSL connection
53if [ "$TYPE" = "xDSL" ] ; then
54    if [ -x /sbin/adsl-start -o -x /usr/sbin/adsl-start ] ; then
55        adsl-start /etc/sysconfig/network-scripts/$CONFIG
56        exit $?
57    else
58        logger -p daemon.info -t ifup-ppp \
59            $"adsl-start does not exist or is not executable for ${DEVICE}"
60        exit 1
61    fi
62fi
63
64PEERCONF=/etc/ppp/peers/${DEVNAME}
65
66if [ "${DEBUG}" = "yes" ]; then
67  CHATDBG="-v"
68fi
69
70if [ ! -f ${PEERCONF} ]; then
71  if [ -z "${WVDIALSECT}" ] ; then
72    CHATSCRIPT=/etc/sysconfig/network-scripts/chat-${DEVNAME}
73    [ -f ${CHATSCRIPT} ] || {
74      CHATSCRIPT=/etc/sysconfig/network-scripts/chat-${PARENTDEVNAME}
75    }
76    [ -f ${CHATSCRIPT} ] || {
77     echo $"/etc/sysconfig/network-scripts/chat-${DEVNAME} does not exist"
78     echo $"ifup-ppp for ${DEVNAME} exiting"
79     logger -p daemon.info -t ifup-ppp \
80       $"/etc/sysconfig/network-scripts/chat-${DEVNAME} does not exist for ${DEVICE}"
81     exit 1
82    }
83  fi
84  logger -s -p daemon.notice -t ifup-ppp \
85    $"Setting up a new ${PEERCONF} config file"
86  if [ -f /etc/ppp/peers/${DEVICE} ]; then
87    cp -f /etc/ppp/peers/${DEVICE} ${PEERCONF}
88  else
89    touch ${PEERCONF}
90  fi
91  if [ "${WVDIALSECT}" ]; then
92    echo "connect \"/usr/bin/wvdial --remotename ${DEVNAME} --chat '${WVDIALSECT}'\"" >> ${PEERCONF}
93  else
94    echo "connect \"/usr/sbin/chat ${CHATDBG} -f ${CHATSCRIPT}\"" >> ${PEERCONF}
95  fi
96fi
97   
98opts="lock"
99if [ "${HARDFLOWCTL}" != no ] ; then
100  opts="$opts modem crtscts"
101fi
102if [ "${ESCAPECHARS}" != yes ] ; then
103  opts="$opts asyncmap 00000000"
104fi
105if [ "${DEFROUTE}" != no ] ; then
106  # pppd will no longer delete an existing default route
107  # so we have to help it out a little here.
108  DEFRT=$(ip route list match 0/0)
109  [ -n "${DEFRT}" ] && echo "$DEFRT" > /etc/default-routes
110  echo "$DEFRT" | while read spec; do
111      ip route del $spec;
112  done
113  opts="$opts defaultroute"
114fi
115if [ "${PEERDNS}" != no ] ; then
116  cp -f /etc/resolv.conf /etc/resolv.conf.save
117  opts="$opts usepeerdns"
118fi
119if [ -n "${MRU}" ] ; then
120  opts="$opts mru ${MRU}"
121fi
122if [ -n "${MTU}" ] ; then
123  opts="$opts mtu ${MTU}"
124fi
125if [ -n "${IPADDR}${REMIP}" ] ; then
126  # if either IP address is set, the following will work.
127  opts="$opts ${IPADDR}:${REMIP}"
128fi
129if [ -n "${PAPNAME}" ] ; then
130  opts="$opts user ${PAPNAME} remotename ${DEVNAME}"
131fi
132if [ "${DEBUG}" = yes ] ; then
133  opts="$opts debug"
134fi
135
136if [ ${DEMAND} = yes ] ; then
137  opts="$opts demand ktune idle ${IDLETIMEOUT} holdoff ${RETRYTIMEOUT}"
138  exec=
139else
140  opts="$opts nodetach"
141  exec=exec
142fi
143
144(logger -p daemon.info -t ifup-ppp \
145  $"pppd started for ${DEVNAME} on ${MODEMPORT} at ${LINESPEED}" &)&
146
147$exec pppd $opts ${MODEMPORT} ${LINESPEED} \
148    ipparam ${DEVNAME} linkname ${DEVNAME} call ${DEVNAME}\
149    noauth \
150    ${PPPOPTIONS} || exit
151
152if [ "${DEMAND}" = "yes" ] ; then
153  # pppd is a tad slow to write the pid-file.
154  sleep 2
155  if [ -f /var/run/ppp-${DEVNAME}.pid ] ; then
156    REALDEVICE=`tail -1 /var/run/ppp-${DEVNAME}.pid`
157    /etc/sysconfig/network-scripts/ifup-routes ${REALDEVICE} ${DEVNAME}
158  fi
159fi
160
Note: See TracBrowser for help on using the repository browser.