Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
if [ -r /etc/defaults/periodic.conf ]; then |
4 |
. /etc/defaults/periodic.conf |
5 |
source_periodic_confs |
6 |
fi |
7 |
|
8 |
: "${daily_checkrestart_enable:=NO}" |
9 |
: "${daily_checkrestart_weekdays:=1234567}" # Days of the week to run, Monday=1 |
10 |
: "${daily_checkrestart_users:=}" # User names or IDs to check |
11 |
: "${daily_checkrestart_jails:=}" # Jail names or IDs to check |
12 |
: "${daily_checkrestart_procs:=}" # Process names or IDs to check |
13 |
|
14 |
checkrestartcmd=/usr/local/bin/checkrestart |
15 |
hflag="" |
16 |
rc=0 |
17 |
|
18 |
export COLUMNS=80 |
19 |
|
20 |
checkrestart() { |
21 |
local result |
22 |
result="$(${checkrestartcmd} ${hflag} "$@" -- ${daily_checkrestart_procs} 2>&1)" |
23 |
if [ "$result" ]; then |
24 |
echo "${result}" |
25 |
rc=3 |
26 |
fi |
27 |
hflag="-H" |
28 |
} |
29 |
|
30 |
checkrestart_each_user() { |
31 |
if [ -n "${daily_checkrestart_users}" ]; then |
32 |
for user in ${daily_checkrestart_users}; do |
33 |
checkrestart -u "${user}" "$@" |
34 |
done |
35 |
else |
36 |
checkrestart "$@" |
37 |
fi |
38 |
} |
39 |
|
40 |
checkrestart_start() { |
41 |
if [ -n "${daily_checkrestart_jails}" ]; then |
42 |
for jail in ${daily_checkrestart_jails}; do |
43 |
checkrestart_each_user -j "${jail}" |
44 |
done |
45 |
else |
46 |
checkrestart_each_user |
47 |
fi |
48 |
} |
49 |
|
50 |
checkday() { |
51 |
if echo "${daily_checkrestart_weekdays}" | grep -vq '^[1-7, ]*$'; then |
52 |
echo "daily_checkrestart_weekdays must have values 1-7" |
53 |
exit 2 |
54 |
fi |
55 |
|
56 |
echo "${daily_checkrestart_weekdays}" | grep -Fq "$(date +%u)" |
57 |
} |
58 |
|
59 |
case "${daily_checkrestart_enable}" in |
60 |
[Yy][Ee][Ss]) |
61 |
if checkday; then |
62 |
echo |
63 |
echo 'Checking for stale processes:' |
64 |
checkrestart_start |
65 |
fi |
66 |
;; |
67 |
esac |
68 |
|
69 |
exit $rc |