Debian Codegraph @

scripts/poff

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