home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / sbin / ppp-off < prev    next >
Encoding:
Text File  |  2004-02-26  |  1.7 KB  |  63 lines

  1. #!/bin/bash
  2. #
  3. # This is the standard ppp-off script that comes with ppp-2.?.?, it's
  4. # been expanded to include the -d option for pppsetup. (1-17-98)
  5. #
  6. ######################################################################
  7. #
  8. # Determine the device to be terminated.
  9. #
  10. if [ "$1" = "" ]; then
  11.     DEVICE=ppp0
  12. elif [ ! "$1" = "-d" ]; then
  13.     DEVICE=$1    
  14. elif [ "$1" = "-d" ]; then
  15.     DEVICE=ppp0    
  16. elif [ ! "$1" = "" ] && [ "$2" = "-d" ]; then
  17.     DEVICE=$1    
  18. fi
  19. ######################################################################
  20. #
  21. # This just checks if demand dialing is running, if so it
  22. # says Demand Dialing Stoped.
  23.  
  24. if ps x | fgrep "options.demand" 1> /dev/null 2> /dev/null ; then
  25.         D="echo Demand Dialing Stoped."
  26. fi
  27.  
  28. #
  29. # If the ppp0 pid file is present then the program is running. Stop it.
  30. if [ -r /var/run/$DEVICE.pid ]; then
  31.         kill -INT `cat /var/run/$DEVICE.pid`
  32. #
  33. # If the kill did not work then there is no process running for this
  34. # pid. It may also mean that the lock file will be left. You may wish
  35. # to delete the lock file at the same time.
  36.         if [ ! "$?" = "0" ]; then
  37.             killall -INT pppd 2>/dev/null
  38.                 rm -f /var/run/$DEVICE.pid
  39.                 rm -f /var/lock/LCK*
  40.                 echo "ERROR: No pppd process running, removed stale pid file."
  41.                 exit 1
  42.         fi
  43. #
  44. # Success. Let pppd clean up its own junk.
  45.         echo "PPP link to [$DEVICE] terminated."
  46.         $D
  47.         if [ "$1" = "-d" ]; then
  48.     pppd file "/etc/ppp/options.demand" || exit 1
  49.     echo "Demand Dialing Started."
  50.     exit 0
  51.     elif [ "$2" = "-d" ]; then
  52.     pppd file "/etc/ppp/options.demand" || exit 1
  53.     echo "Demand Dialing Started."
  54.     exit 0
  55.     else
  56.     exit 0
  57. fi
  58. fi
  59. #
  60. # The ppp process is not running for ppp0
  61. echo "ERROR: PPP link is not active on: [$DEVICE]"
  62. exit 1
  63.