[1108] | 1 | #! /bin/bash |
---|
| 2 | |
---|
| 3 | . /etc/init.d/functions |
---|
| 4 | |
---|
| 5 | cd /etc/sysconfig/network-scripts |
---|
[2573] | 6 | . /etc/sysconfig/network-scripts/network-functions |
---|
[1108] | 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 /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 |
---|
| 53 | if [ "$TYPE" = "xDSL" ] ; then |
---|
[4352] | 54 | if [ -x /sbin/pppoe-start -o -x /usr/sbin/pppoe-start ] ; then |
---|
| 55 | pppoe-start /etc/sysconfig/network-scripts/$CONFIG |
---|
[1108] | 56 | exit $? |
---|
| 57 | else |
---|
| 58 | logger -p daemon.info -t ifup-ppp \ |
---|
[4352] | 59 | $"pppoe-start does not exist or is not executable for ${DEVICE}" |
---|
[1108] | 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 | 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 |
---|
| 96 | fi |
---|
| 97 | |
---|
| 98 | opts="lock" |
---|
| 99 | if [ "${HARDFLOWCTL}" != no ] ; then |
---|
| 100 | opts="$opts modem crtscts" |
---|
| 101 | fi |
---|
| 102 | if [ "${ESCAPECHARS}" != yes ] ; then |
---|
| 103 | opts="$opts asyncmap 00000000" |
---|
| 104 | fi |
---|
| 105 | if [ "${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" |
---|
| 114 | fi |
---|
| 115 | if [ "${PEERDNS}" != no ] ; then |
---|
| 116 | cp -f /etc/resolv.conf /etc/resolv.conf.save |
---|
| 117 | opts="$opts usepeerdns" |
---|
| 118 | fi |
---|
| 119 | if [ -n "${MRU}" ] ; then |
---|
| 120 | opts="$opts mru ${MRU}" |
---|
| 121 | fi |
---|
| 122 | if [ -n "${MTU}" ] ; then |
---|
| 123 | opts="$opts mtu ${MTU}" |
---|
| 124 | fi |
---|
| 125 | if [ -n "${IPADDR}${REMIP}" ] ; then |
---|
| 126 | # if either IP address is set, the following will work. |
---|
| 127 | opts="$opts ${IPADDR}:${REMIP}" |
---|
| 128 | fi |
---|
| 129 | if [ -n "${PAPNAME}" ] ; then |
---|
| 130 | opts="$opts user ${PAPNAME} remotename ${DEVNAME}" |
---|
| 131 | fi |
---|
| 132 | if [ "${DEBUG}" = yes ] ; then |
---|
| 133 | opts="$opts debug" |
---|
| 134 | fi |
---|
| 135 | |
---|
| 136 | if [ ${DEMAND} = yes ] ; then |
---|
| 137 | opts="$opts demand ktune idle ${IDLETIMEOUT} holdoff ${RETRYTIMEOUT}" |
---|
| 138 | exec= |
---|
| 139 | else |
---|
| 140 | opts="$opts nodetach" |
---|
| 141 | exec=exec |
---|
| 142 | fi |
---|
| 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 | |
---|
| 152 | if [ "${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 |
---|
| 159 | fi |
---|
| 160 | |
---|