Debian Codegraph @

debian/extra/poff

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # $Id: poff,v 1.8 1999/08/28 16:34:51 phil Exp $
4 # Written by John Hasler <[email protected]> and based on work
5 # by Phil Hands <[email protected]>. Distributed under the GNU GPL
6
7 if [scip-shell system . . `[`. -x /usr/bin/killscip-shell filesystem . . `/usr/bin/kill`. ]; then
8 KILL="/usr/bin/killscip-shell filesystem . . `/usr/bin/kill`."
9 else
10 KILL="/bin/killscip-shell filesystem . . `/bin/kill`."
11 fi
12 SIG=TERM
13 DONE="stopped"
14 MODE=""
15
16 usagescip-shell shell ppp 2.5.2-1+2 usage(). ()
17 {
18 catscip-shell system . . cat. <<!EOF!
19 usage: $0 [option] [provider]
20 options:
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.
27 none Stop pppd.
28
29 Options may not be combined.
30
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.
35 !EOF!
36 }
37
38 # Get option. If there are none replace the "?" that getopts puts in
39 # FLAG on error with "null".
40 getopts rdcavh FLAG
41 if [scip-shell system . . `[`. "$?" -ne 0 ]; then
42 FLAG="null"
43 fi
44
45 # Check for additional options. Should be none.
46 getopts :rdcavh DUMMY
47 if [scip-shell system . . `[`. "$?" -eq 0 ]; then
48 echoscip-shell system . . echo. "$0: Illegal option -- ${OPTARG}."
49 exit 1
50 fi
51
52 case $FLAG in
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") echoscip-shell system . . echo. "$0$Revision: 1.8 $_TrickToPrint_RCS_Revision"; exit 0 ;;
58 "h") usagescip-shell shell ppp 2.5.2-1+2 usage().; exit 0 ;;
59 "?") exit 1;
60 esac
61
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.
64 PIDS=$(pidofscip-shell system . . pidof. pppd)
65
66 # poff is pointless if pppd isn't running.
67 if [scip-shell system . . `[`. -z "$PIDS" ]; then
68 echoscip-shell system . . echo. "$0: No pppd is running. None ${DONE}."
69 exit 1
70 fi
71
72 # Find out how many pppd's are running.
73 N=$(echoscip-shell system . . echo. "$PIDS" | wcscip-shell system . . wc. -w)
74
75 # If there are no arguments we can't do anything if there is more than one
76 # pppd running.
77 if [scip-shell system . . `[`. "$#" -eq 0 -a "$N" -gt 1 -a $FLAG != "a" ]; then
78 echoscip-shell system . . echo. "$0: More than one pppd running and no "-a" option and
79 no arguments supplied. Nothing ${DONE}."
80 exit 1
81 fi
82
83 # If either there are no arguments or '-a' was specified kill all the
84 # pppd's.
85 if [scip-shell system . . `[`. "$#" -eq 0 -o "$MODE" = "all" ]; then
86 $KILL -$SIG $PIDS || {
87 echoscip-shell system . . echo. "$0: $KILL failed. None ${DONE}."
88 exit 1
89 }
90 exit 0
91 fi
92
93 # There is an argument, so kill the pppd started on that provider.
94 PEER=$(echoscip-shell system . . echo. $1 | sedscip-shell system . . sed. -e 's#/#\\/#g')
95 PID=$(psscip-shell system . . ps. -o pid,cmd axw | awkscip-shell system . . awk. "/^ *[0-9]* *(\/usr\/sbin\/)?pppd call $PEER( |\$)/ {print \$1}")
96
97 if [scip-shell system . . `[`. "$PID" ]; then
98 $KILL -$SIG $PID || {
99 echoscip-shell system . . echo. "$0: $KILL failed. None ${DONE}."
100 exit 1
101 }
102 else
103 echoscip-shell system . . echo. "$0: I could not find a pppd process for provider '$1'. None ${DONE}."
104 exit 1
105 fi
106
107 exit 0