3 # $Id: poff,v 1.1 2002/11/24 23:30:44 etbe Exp $
4 # Written by John Hasler <john@dhh.gt.org> and based on work
5 # by Phil Hands <phil@hands.com>. Distributed under the GNU GPL
7 if [ -x /usr
/bin
/kill ]; then
19 usage
: $0 [option
] [provider
]
21 -r Cause pppd to drop the line and redial.
22 -d Toggle the state of pppd
's debug option.
23 -c Cause pppd to renegotiate compression.
24 -a Stop all pppd's.
'provider' will be ignored.
25 -h Print this
help summary and
exit.
26 -v Print version and
exit.
29 Options may not be combined.
31 If
'provider' is omitted pppd will be stopped or signalled
if and only
if
32 there is exactly one running unless the
'-a' option was given. If
33 'provider' is supplied the pppd controlling the connection to that
34 provider will be stopped or signalled.
38 # Get option. If there are none replace the "?" that getopts puts in
39 # FLAG on error with "null".
41 if [ "$?" -ne 0 ]; then
45 # Check for additional options. Should be none.
47 if [ "$?" -eq 0 ]; then
48 echo "$0: Illegal option -- ${OPTARG}."
53 "r") SIG
=HUP
; DONE
=signalled
; shift ;;
54 "d") SIG
=USR1
; DONE
=signalled
; shift ;;
55 "c") SIG
=USR2
; DONE
=signalled
; shift ;;
56 "a") MODE
="all"; shift ;;
57 "v") echo "$0$Revision: 1.1 $_TrickToPrint_RCS_Revision"; exit 0 ;;
62 # Get the PIDs of all the pppds running. Could also get these from
63 # /var/run, but pppd doesn't create .pid files until ppp is up.
66 # poff is pointless if pppd isn't running.
67 if test -z "$PIDS"; then
68 echo "$0: No pppd is running. None ${DONE}."
72 # Find out how many pppd's are running.
73 N
=`echo "$PIDS" | wc -w`
75 # If there are no arguments we can't do anything if there is more than one
77 if test "$#" -eq 0 -a "$N" -gt 1 -a $FLAG != "a" ; then
78 echo "$0: More than one pppd running and no "-a" option and
79 no arguments supplied. Nothing ${DONE}."
83 # If either there are no arguments or '-a' was specified kill all the
85 if test "$#" -eq 0 -o "$MODE" = "all" ; then
86 $KILL -$SIG $PIDS ||
{
87 echo "$0: $KILL failed. None ${DONE}."
93 # There is an argument, so kill the pppd started on that provider.
94 PID
=`ps axw | grep "[ /]pppd call $1 *\$" | awk '{print $1}'`
95 if test -n "$PID" ; then
97 echo "$0: $KILL failed. None ${DONE}."
101 echo "$0: I could not find a pppd process for provider '$1'. None ${DONE}."