-
Notifications
You must be signed in to change notification settings - Fork 1
/
check-pots.sh
executable file
·52 lines (44 loc) · 1.29 KB
/
check-pots.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
#!/bin/sh
set -eu
# Debug any running pots by performing a basic healthcheck
check_tree() {
if [ -e $1 ]; then
if [ "$(ls $1 | wc -l)" -eq 0 ]; then
echo "[debug] $1 for $pot is empty"
fi
else
echo "[warning] $1 for $pot was not found"
fi
}
check_pot() {
# Are needed rcvars enabled for the pot?
rcvar=$(pot exec -p $pot sysrc sshd_enable)
if [ "$(echo $rcvar | grep -o NO )" ]; then
echo "[warning] sshd is disabled on $pot"
fi
# Is the pot configured to use pkg?
for pkg in pkg64 pkg64c pk64cb; do
if [ -z "$(pot exec -p $pot which $pkg)" ]; then
echo "[warning] $pkg on $pot was not found"
fi
# Does the pot have mounted package caches?
dir=/opt/pot/jails/$pot/m/var/cache/$pkg
check_tree $dir
done
# Does the pot have mounted libraries?
for lib in lib64 lib64c lib64cb; do
dir=/opt/pot/jails/$pot/m/usr/$lib
check_tree $dir
done
}
echo "[debug] attempting healthchecks on all pots currently active"
pots=$(pot ps | grep -v '===' | wc -l)
if [ "$(echo $pots)" -gt 0 ]; then
for pot in $pots; do
echo "[debug] checking $pot"
check_pot
done
else
echo "[debug] no active pots found"
fi
echo "[debug] healthchecks complete"