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