Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

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