From 099a37aa07a19221942b6a7b1f3074d873cdc3b1 Mon Sep 17 00:00:00 2001 From: doc Date: Wed, 9 Jul 2025 20:24:48 +0000 Subject: initial --- slogthedog.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 slogthedog.sh diff --git a/slogthedog.sh b/slogthedog.sh new file mode 100755 index 0000000..7e00a4b --- /dev/null +++ b/slogthedog.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# slogthedog.sh - Detect ZFS pools missing SLOGs and offer to add one. +# Because sometimes the sync log needs a good boy. + +clear +cat << "EOF" + __ + __ /o \_ +<___/---' +🐢 SLOG THE DOG v1.0 +------------------------------- + Fetching sync logs since 2025 +EOF + +echo "" +echo "πŸ” Scanning ZFS pools for missing SLOGs..." + +for pool in $(zpool list -H -o name); do + if ! zpool status "$pool" | grep -q 'logs'; then + echo "πŸ›‘ Pool '$pool' has no SLOG." + echo -n "Do you want to add a SLOG device to this pool? [y/N]: " + read answer + if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then + echo "" + echo "🐾 Available GPT-capable drives:" + gpart show | grep "GPT" | awk '{print $1}' | sort -u + echo -n "πŸ‘‰ Enter device name to use (e.g. nvd0 or nvme0n1): " + read dev + echo "" + echo "🧼 Prepping /dev/$dev..." + gpart destroy -F /dev/$dev >/dev/null 2>&1 + gpart create -s GPT /dev/$dev + gpart add -t freebsd-zfs -l slog_${pool} -s 16G /dev/$dev + echo "βž• Adding /dev/gpt/slog_${pool} as log device to $pool..." + zpool add "$pool" log /dev/gpt/slog_${pool} + echo "βœ… SLOG added to pool '$pool' using /dev/gpt/slog_${pool}" + echo "" + else + echo "❌ Skipping pool '$pool'" + fi + else + echo "βœ… Pool '$pool' already has a SLOG." + fi +done + +echo "" +echo "🏁 Done. Slog the Dog is waggin’ his tail. All pools checked." -- cgit v1.2.3