summaryrefslogtreecommitdiff
path: root/rebootvalidate.sh
blob: f6506e68511b1fae86bc20fc95d3b9bc140fd36c (plain)
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
#!/bin/bash
# rebootvalidate.sh - Validate ZFS pools, datasets, and bind mounts after reboot

# === CONFIG ===
# List the bind mount TARGETS you expect to be present under /mnt/brimstone/mirror
EXPECTED_BINDS=(
  "/mnt/brimstone/mirror/archlinux"
  "/mnt/brimstone/mirror/rocky"
  "/mnt/brimstone/mirror/debian"
  "/mnt/brimstone/mirror/slackware"
  "/mnt/brimstone/mirror/gentoo"
  "/mnt/brimstone/mirror/hardenedbsd"
  "/mnt/brimstone/mirror/void"
  "/mnt/brimstone/mirror/crux"
  "/mnt/brimstone/mirror/alma"
  "/mnt/brimstone/mirror/kitten"
)

echo "=== Checking ZFS Pools ==="
zpool status | grep -E "pool|state|errors"
if zpool status | grep -q "ONLINE"; then
  echo "[OK] All pools appear ONLINE."
else
  echo "[WARN] Some pools are not ONLINE."
fi
echo

echo "=== Checking ZFS Datasets ==="
zfs list -o name,mountpoint,mounted | grep -v "legacy"
if zfs list -o mounted | grep -q "no"; then
  echo "[WARN] One or more datasets are not mounted."
else
  echo "[OK] All datasets mounted."
fi
echo

echo "=== Checking Bind Mounts ==="
for target in "${EXPECTED_BINDS[@]}"; do
  if findmnt -no TARGET,SOURCE "$target" >/tmp/mntcheck 2>/dev/null; then
    tgt=$(awk '{print $1}' /tmp/mntcheck)
    src=$(awk '{print $2}' /tmp/mntcheck)

    if [[ "$tgt" == "$target" ]]; then
      echo "[OK] $target is bound to $src"
    else
      echo "[FAIL] $target exists but unexpected source: $src"
    fi
  else
    echo "[FAIL] Missing bind mount: $target"
  fi
done