-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwash-watch.sh
executable file
·68 lines (50 loc) · 1021 Bytes
/
wash-watch.sh
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
#!/bin/sh
bname=$(basename $0)
service=wash-watch
file=/var/tmp/wash-watch.alive
run_test ()
{
local err=0
echo -n "Checking wash-watch... "
systemctl is-active --quiet ${service}
if [ $? -eq 0 ]; then
sleep 1
alive=$(find ${file} -cmin +5 2>/dev/null)
if [ -f ${file} -a -z ${alive} ]; then
echo "appears alive."
else
err=1
echo "appears dead."
fi
else
echo "not running."
fi
return ${err}
}
run_repair ()
{
local param="$1"
local err=0
if [ -z "${param}" ] ; then
echo "Missing error code (parameter) for repair"
return 23
fi
echo "Restarting ${service}..."
systemctl restart ${service}
return ${err}
}
err=0
case "$1" in
test)
run_test
err=$?
;;
repair)
run_repair "$2"
err=$?
;;
*)
echo "Usage: ${bname} {test|repair errcode}"
err=23
esac
exit ${err}