LJ Archive

Example ppp-off Script

  #!/bin/sh
  #
  # ppp-off -- shutdown a running ppp daemon
  # this was taken directly from the pppd-2.1.2d Linux FAQ

  piddir=/var/run
  if [ -n "$1" ]; then
    pppdev=$1
  else
    pppdev=ppp0
  fi
  # exit sts
  sts=0

  # If the pid file is present then pppd is running. Stop it.
  if [ -r $piddir/$pppdev.pid ]; then
    if kill -INT `cat $piddir/$pppdev.pid`; then
      # Success. Let pppd clean up its own junk.
      echo "$0: ppp link to $pppdev terminated."
      sts=0
    else
      # If the kill did not work then there is no process running for
      # this pid. It may also mean that the lock file will be left.
      # You may wish to delete the lock file at the same time.
      rm -f $piddir/$pppdev.pid
      echo "$0: Removed stale pid file"
      sts=1
      fi
  else
    # The ppp process is not running for ppp0
    echo "$0: no ppp link is active on $pppdev"
    sts=1
  fi

  # exit with appropriate status
  exit $sts
LJ Archive