home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / sbin / adsl-stop < prev    next >
Encoding:
Text File  |  2003-03-02  |  2.1 KB  |  91 lines

  1. #!/bin/sh
  2. # Generated automatically from adsl-stop.in by configure.
  3. #***********************************************************************
  4. #
  5. # adsl-stop
  6. #
  7. # Shell script to bring down an ADSL connection
  8. #
  9. # Copyright (C) 2000 Roaring Penguin Software Inc.
  10. #
  11. # $Id: adsl-stop.in,v 1.5 2002/04/09 17:28:39 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: adsl-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.  
  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 adsl-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 adsl-start
  72.     PIDS=`cat $STARTPID`
  73.     kill -0 $PIDS > /dev/null 2>&1
  74.     if [ $? = 0 ] ; then
  75.     $LOGGER -p daemon.notice "Killing adsl-connect"
  76.     kill $PIDS > /dev/null 2>&1
  77.     fi
  78.  
  79.     # Kill adsl-connect
  80.     $LOGGER -p daemon.notice "Killing adsl-connect"
  81.     echo "Killing adsl-connect ($PID)"
  82.     kill $PID > /dev/null 2>&1
  83.  
  84.     rm -f "$PIDFILE" "$PPPD_PIDFILE" "$PPPOE_PIDFILE" "$STARTPID"
  85. else
  86.     echo "$ME: No ADSL connection appears to be running" >&2
  87.     exit 1
  88. fi
  89.  
  90. exit 0
  91.