head	1.4;
access;
symbols;
locks; strict;
comment	@# @;


1.4
date	98.05.26.14.46.08;	author phil;	state Exp;
branches;
next	1.3;

1.3
date	98.02.26.06.42.45;	author phil;	state Exp;
branches;
next	1.2;

1.2
date	98.02.26.06.37.46;	author phil;	state Exp;
branches;
next	1.1;

1.1
date	98.02.26.06.17.46;	author phil;	state Exp;
branches;
next	;


desc
@@


1.4
log
@use patch from steveh@@eecs.umich.edu to allow handling multiple instances
of pppd
@
text
@#!/bin/sh

# $Id: poff,v 1.3 1998/02/26 06:42:45 phil Exp $
# Written by Phil Hands <phil@@hands.com>, distributed under the GNU GPL

SIG=TERM DONE=stopped;

getopts rdch FLAG
case $FLAG in
 "r") SIG=HUP  DONE=signalled; shift  ;;
 "d") SIG=USR1 DONE=signalled; shift ;;
 "c") SIG=USR2 DONE=signalled; shift ;;
 "h") cat <<!EOF!
usage: $0 [options] [provider]

options:
  -r        cause pppd to drop the line and redial
  -d        toggles the state of pppd's debug option
  -c        cause pppd to renegotiate compression
  -h        this help summary
!EOF!
    exit 1
    ;;
esac

PROVIDER=$1


# Lets see how many pppds are running....
set -- `cat /var/run/ppp*.pid 2>/dev/null`

case $# in
  0) # pppd only creates a pid file once ppp is up, so let's try killing pppd
     # on the assumption that we've not got that far yet.
     kill -${SIG} `ps axw | egrep "pppd call [[:alnum:]]+" | grep -v grep | awk '{print $1}'`
     exit 0
     ;;
  1) # If only one was running then it can be killed using the pid
     kill -${SIG} $1
     exit 0
     ;;
  *) # More than one! Aieehh.. We have to use ps to figure it out.
     # If no arguments were specified, then assume the 'provider' default.
     PID=`ps axw | egrep "pppd call ${PROVIDER:-provider}[[:space:]]*\$" | grep -v grep | awk '{print $1}'`
     if [ $PID ]; then
        kill -${SIG} ${PID}
        exit 0
     else
        echo "I could not find a pppd process or provider '${PROVIDER:-provider}'. None ${DONE}"
        exit 1
     fi
     ;;
esac
@


1.3
log
@add $Id:$
@
text
@d3 1
a3 1
# $Id:$
d6 9
a14 7
case $1 in
 "")   SIG=TERM DONE=stopped ;;
 "-r") SIG=HUP  DONE=signalled ;;
 "-d") SIG=USR1 DONE=signalled ;;
 "-c") SIG=USR2 DONE=signalled ;;
 *) cat <<!EOF!
usage: $0 [options]
d20 1
d26 3
d35 1
a35 1
     killall -${SIG} pppd
d38 1
a38 2
  1) # If only one was running then it can be killed (apparently killall
     # caused problems for some, so lets try killing the pid from the file)
d42 10
a51 3
  *) # More than one! Aieehh.. Dont know which one to kill.
     echo "More than one pppd running. None ${DONE}"
     exit 1
@


1.2
log
@add options to allow alternative signals to be sent
@
text
@d3 3
@


1.1
log
@Initial revision
@
text
@d3 17
d26 1
a26 1
     killall pppd
d31 1
a31 1
     kill $1
d35 1
a35 1
     echo "More than one pppd running. None stopped"
@
