home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / pppoe-stop < prev    next >
Encoding:
Text File  |  2005-12-20  |  2.3 KB  |  97 lines

  1. #!/bin/sh
  2. # ../scripts/pppoe-stop.  Generated from pppoe-stop.in by configure.
  3. #***********************************************************************
  4. #
  5. # pppoe-stop
  6. #
  7. # Shell script to bring down a PPPoE connection
  8. #
  9. # Copyright (C) 2000 Roaring Penguin Software Inc.
  10. #
  11. # $Id: pppoe-stop.in,v 1.2 2005/08/10 00:25:19 dfs Exp $
  12. #
  13. # This file may be distributed under the terms of the GNU General
  14. # Public License.
  15. #
  16. # LIC: GPL
  17. #
  18. # Usage: pppoe-stop [config_file]
  19. # If config_file is omitted, defaults to /etc/ppp/pppoe.conf
  20. #
  21. #***********************************************************************
  22.  
  23. # Set to "C" locale so we can parse messages from commands
  24. LANG=C
  25. export LANG
  26.  
  27. ME="`basename $0`"
  28. LOGGER="/usr/bin/logger -t $ME"
  29. CONFIG="$1"
  30. if [ "$CONFIG" = "" ] ; then
  31.     CONFIG=/etc/ppp/pppoe.conf
  32. fi
  33.  
  34. if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then
  35.     echo "$ME: Cannot read configuration file '$CONFIG'" >& 2
  36.     exit 1
  37. fi
  38. export CONFIG
  39. . $CONFIG
  40.  
  41. PPPOE_PIDFILE="$PIDFILE.pppoe"
  42. PPPD_PIDFILE="$PIDFILE.pppd"
  43. STARTPID="$PIDFILE.start"
  44.  
  45. # Backward config file compatibility
  46. if test "$DEMAND" = "" ; then
  47.     DEMAND=no
  48. fi
  49.  
  50. # Ignore SIGTERM
  51. trap "" 15
  52.  
  53. # Check for pidfile
  54. if [ -r "$PIDFILE" ] ; then
  55.     PID=`cat $PIDFILE`
  56.  
  57.     # Check if still running
  58.     kill -0 $PID > /dev/null 2>&1
  59.     if [ $? != 0 ] ; then
  60.     echo "$ME: The pppoe-connect script (PID $PID) appears to have died" >& 2
  61.     fi
  62.  
  63.     # Kill pppd, which should in turn kill pppoe
  64.     if [ -r "$PPPD_PIDFILE" ] ; then
  65.     PPPD_PID=`cat "$PPPD_PIDFILE"`
  66.     $LOGGER -p daemon.notice "Killing pppd"
  67.     echo "Killing pppd ($PPPD_PID)"
  68.     kill $PPPD_PID > /dev/null 2>&1 || exit 1
  69.     fi
  70.  
  71.     # Kill pppoe-start
  72.     PIDS=`cat $STARTPID`
  73.     kill -0 $PIDS > /dev/null 2>&1
  74.     if [ $? = 0 ] ; then
  75.     $LOGGER -p daemon.notice "Killing pppoe-connect"
  76.     kill $PIDS > /dev/null 2>&1
  77.     fi
  78.  
  79.     # Kill pppoe-connect
  80.     $LOGGER -p daemon.notice "Killing pppoe-connect"
  81.     echo "Killing pppoe-connect ($PID)"
  82.     kill -9 $PID > /dev/null 2>&1
  83.  
  84.     # Kill pppd again, in case it's still hanging around
  85.     if [ -r "$PPPD_PIDFILE" ] ; then
  86.     PPPD_PID=`cat "$PPPD_PIDFILE"`
  87.     kill -9 $PPPD_PID > /dev/null 2>&1 || exit 1
  88.     fi
  89.  
  90.     rm -f "$PIDFILE" "$PPPD_PIDFILE" "$PPPOE_PIDFILE" "$STARTPID"
  91. else
  92.     echo "$ME: No PPPoE connection appears to be running" >&2
  93.     exit 1
  94. fi
  95.  
  96. exit 0
  97.