-
Notifications
You must be signed in to change notification settings - Fork 4
/
afvctl
executable file
·71 lines (66 loc) · 1.47 KB
/
afvctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
# afvctl
# File ID: 0bd0b80a-5d37-11df-a6ed-90e6ba3022ac
# Starter/stopper/viser status for alle afv’er
# FIXME: Dette skulle egentlig vært integrert i afv(1).
afvdir=$AFVROOT$(/bin/pwd)
currstop=$afvdir/stop
dontstop=$afvdir/protected
retval=0
case "$1" in
start)
echo -n Starter afv …
rm -f $currstop
retval=$?
;;
stop)
echo -n Stopper afv …
touch $currstop
sleep 5
rm $currstop
retval=$?
;;
startall)
echo -n Starter alle afv’er …
rm -f $AFVROOT/stop
retval=$?
;;
stopall)
echo -n Stopper alle afv’er …
touch $AFVROOT/stop
sleep 5
rm $AFVROOT/stop
retval=$?
;;
stat*)
ps auxw | grep afv | grep -v -e 'afvctl stat' -e 'grep afv' -e 'grep -v -e '
retval=$?
exit $retval;
;;
protect*)
[ -d $afvdir ] || mkdir -p $afvdir || { echo "$0: mkdir $afvdir: Gikk visst dårlig."; }
touch $dontstop || [ -e $dontstop ] || { echo "$0: $dontstop: Fila ble visst ikke opprettet. Hm. Muskelmanko?." >&2; retval=1; }
echo Katalogen `/bin/pwd` er nå beskyttet mot «afvctl stop*»...
;;
unprotect*)
if [ -e $dontstop ]; then
rm $dontstop || { echo "$0: $dontstop: Klarte ikke å slette fila, katalogen er fortsatt beskyttet." >&2; exit 1; }
echo Fjernet stoppbeskyttelsen.
else
echo Katalogen er jo egentlig ikke beskyttet, da...
exit 0;
fi
;;
*)
echo
echo Syntax: $0 start\|stop\|stat\|protect\|unprotect
echo
exit 1
;;
esac
if [ "$retval" = "0" ]; then
echo OK
else
echo FEIL \($retval\)
fi
exit $retval