diff options
Diffstat (limited to 'sysconfig')
-rwxr-xr-x | sysconfig/network-scripts/ifdown-ppp | 45 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ppp | 71 |
2 files changed, 28 insertions, 88 deletions
diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp index 6f1d90ca..2e56b0c0 100755 --- a/sysconfig/network-scripts/ifdown-ppp +++ b/sysconfig/network-scripts/ifdown-ppp @@ -7,47 +7,24 @@ cd /etc/sysconfig/network-scripts CONFIG=$1 source_config -if [ ! -f /var/run/ppp-$DEVICE.pid ]; then - # ppp isn't running, or we didn't start it - exit 0 -fi - -file=/var/run/ppp-$DEVICE.pid - -# signals ifup-ppp not to persist -- must do this before exiting if PPP -# has not yet started ($file does not exist). -rm -f /var/run/ppp-$DEVICE.dev +file=/var/run/pppwatch-$DEVICE.pid if [ ! -f $file ]; then + # ppp isn't running, or we didn't start it exit 0 fi -PID=`head -1 $file` -if [ -z "$PID" ]; then - exit 1 -fi - -# pppd might have chat/wvdial as a child; remember its pid to kill after pppd. -# (After, not before, so that pppd doesn't just restart it). - -CHATPID=`ps axl | awk '$4 ~ /^'"$PID"'$/ {print $3}' 2>/dev/null` +PID=`cat $file` +[ -n "$PID" ] || exit 1 -kill $PID > /dev/null 2>&1 -[ -n "$CHATPID" ] && kill $CHATPID > /dev/null 2>&1 -if [ ! -d /proc/$PID ]; then - exit 0 -fi +kill -TERM $PID > /dev/null 2>&1 +[ ! -d /proc/$PID ] && exit 0 sleep 2 -if [ ! -d /proc/$PID ]; then - exit 0 -fi +[ ! -d /proc/$PID ] && exit 0 -kill -KILL $PID > /dev/null 2>&1 -if [ -d /proc/$PID ]; then - logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" & -else - # ip-down won't run in this case - /etc/sysconfig/network-scripts/ifdown-post $1 -fi +# killing ppp-watch twice in a row causes it to send a SIGKILL to pppd pgrp +kill -TERM $PID > /dev/null 2>&1 +# ip-down won't run in this case +/etc/sysconfig/network-scripts/ifdown-post $1 exit 1 diff --git a/sysconfig/network-scripts/ifup-ppp b/sysconfig/network-scripts/ifup-ppp index 3fd810f7..d058e9b3 100755 --- a/sysconfig/network-scripts/ifup-ppp +++ b/sysconfig/network-scripts/ifup-ppp @@ -4,10 +4,8 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin # ifup-post for PPP is handled through /etc/ppp/ip-up if [ "$1" != daemon ] ; then - # disconnect stdin, out, err to disassociate from controlling tty - # so that no HUPs will get through. - $0 daemon $* </dev/null >/dev/null 2>/dev/null & - exit 0 + # let ppp-watch do the right thing + exec /sbin/ppp-watch "$@" fi shift @@ -87,54 +85,19 @@ else CHATSCRIPT= fi -while : ; do - (logger -p daemon.info -t ifup-ppp \ - "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)& +(logger -p daemon.info -t ifup-ppp \ + "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)& - if [ -n "$WVDIALSECT" ] ; then - /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ - remotename $DEVICE ipparam $DEVICE \ - ${PPPOPTIONS} \ - linkname $DEVICE \ - connect "/usr/bin/wvdial --chat $WVDIALSECT" - else - /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ - remotename $DEVICE ipparam $DEVICE \ - ${PPPOPTIONS} \ - linkname $DEVICE \ - connect "/usr/sbin/chat $chatdbg -f $CHATSCRIPT" - fi - - # exit if we're not supposed to persist or our lock file has disappeared - if [ "$PERSIST" != "yes" -o ! -f /var/run/ppp-$DEVICE.dev ]; then - rm -f /var/run/ppp-$DEVICE.dev - exit 0 - fi - - size=`wc -c < /var/run/ppp-$DEVICE.dev` - - if [ $size = 0 ]; then - # pppd never connected - timeout=$RETRYTIMEOUT - else - # pppd connected and then disconnected - timeout=$DISCONNECTTIMEOUT - fi - - [ -z "$timeout" ] && { - timeout=30 - } - - sleep $timeout || { - # sleep was killed - rm -f /var/run/ppp-$DEVICE.dev - rm -f /var/run/ppp-$DEVICE.pid - exit 0 - } - - # exit if our lock file disappeared while we slept - if [ ! -f /var/run/ppp-$DEVICE.dev ]; then - rm -f /var/run/ppp-$DEVICE.pid - exit 0 - fi -done +if [ -n "$WVDIALSECT" ] ; then + exec /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ + remotename $DEVICE ipparam $DEVICE \ + ${PPPOPTIONS} \ + linkname $DEVICE \ + connect "/usr/bin/wvdial --chat $WVDIALSECT" +else + exec /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \ + remotename $DEVICE ipparam $DEVICE \ + ${PPPOPTIONS} \ + linkname $DEVICE \ + connect "/usr/sbin/chat $chatdbg -f $CHATSCRIPT" +fi |