updated scripts
This commit is contained in:
@@ -209,6 +209,16 @@ print_plan() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LEVEL" == "full" || "$LEVEL" == "nuclear" ]]; then
|
||||
echo ""
|
||||
echo -e "${CYAN}Mount cleanup:${NC}"
|
||||
if [ -d /mnt/.felhom-scan ]; then
|
||||
echo -e " ${YELLOW}DELETE${NC} /mnt/.felhom-scan/ (stale scan dir)"
|
||||
else
|
||||
echo -e " ${GREEN}(no .felhom-scan dir)${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LEVEL" == "full" || "$LEVEL" == "nuclear" ]]; then
|
||||
echo ""
|
||||
echo -e "${CYAN}Storage data:${NC}"
|
||||
@@ -239,6 +249,21 @@ print_plan() {
|
||||
echo -e " ${RED}DELETE${NC} Cloudflared container"
|
||||
echo -e " ${RED}DELETE${NC} Portainer container + volume"
|
||||
echo -e " ${RED}DELETE${NC} .felhom-infra-backup/ (DR markers on all drives)"
|
||||
if [ -d /mnt/.felhom-raw ]; then
|
||||
echo -e " ${RED}UNMOUNT+DELETE${NC} /mnt/.felhom-raw/ (raw helper mounts + fstab entries)"
|
||||
# Show each raw mount and its bind target
|
||||
for rmp in /mnt/.felhom-raw/*/; do
|
||||
[ -d "$rmp" ] || continue
|
||||
local label; label=$(basename "$rmp")
|
||||
local bind_target
|
||||
bind_target=$(grep -E "^/mnt/\.felhom-raw/${label}/" /etc/fstab 2>/dev/null | awk '{print $2}' | head -1 || true)
|
||||
if [ -n "$bind_target" ]; then
|
||||
echo -e " ${RED}umount${NC} ${bind_target} (bind) → ${rmp} (raw)"
|
||||
else
|
||||
echo -e " ${RED}umount${NC} ${rmp} (raw, no bind found)"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo -e " ${RED}DELETE${NC} All Docker data (docker system prune -af --volumes)"
|
||||
echo -e " ${RED}DELETE${NC} $COMPOSE_DIR/ (controller compose + .env)"
|
||||
local infra_root; infra_root=$(dirname "$COMPOSE_DIR")
|
||||
@@ -264,6 +289,57 @@ print_plan() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
# --- Mount Cleanup Helpers ---
|
||||
|
||||
# cleanup_scan_dir: remove /mnt/.felhom-scan/ (ephemeral DR scan staging dir).
|
||||
# Always empty after normal operation; safe to rm -rf unconditionally.
|
||||
cleanup_scan_dir() {
|
||||
if [ -d /mnt/.felhom-scan ]; then
|
||||
rm -rf /mnt/.felhom-scan && info " Removed: /mnt/.felhom-scan/"
|
||||
fi
|
||||
}
|
||||
|
||||
# cleanup_raw_mounts: unmount bind mounts, unmount raw helper mounts, strip
|
||||
# /etc/fstab entries, then remove the now-empty /mnt/.felhom-raw/ directory.
|
||||
#
|
||||
# Raw mounts are created by the attach wizard (two-level: raw partition mount +
|
||||
# bind mount from subfolder). Both fstab entries must be removed so they don't
|
||||
# cause errors on next boot. Order: bind umount first, then raw umount.
|
||||
cleanup_raw_mounts() {
|
||||
[ -d /mnt/.felhom-raw ] || return
|
||||
|
||||
info "Cleaning up raw helper mounts (/mnt/.felhom-raw/)..."
|
||||
|
||||
# 1. Unmount bind mounts whose source is inside .felhom-raw (field 1 matches)
|
||||
if [ -f /etc/fstab ]; then
|
||||
local bind_targets
|
||||
bind_targets=$(grep -E '^/mnt/\.felhom-raw/' /etc/fstab | awk '{print $2}' || true)
|
||||
for mp in $bind_targets; do
|
||||
if mountpoint -q "$mp" 2>/dev/null; then
|
||||
umount -l "$mp" 2>/dev/null && info " Unmounted bind: $mp" \
|
||||
|| warn " Could not unmount bind: $mp"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# 2. Unmount raw partition mounts (field 2 matches /mnt/.felhom-raw/*)
|
||||
for mp in /mnt/.felhom-raw/*/; do
|
||||
[ -d "$mp" ] || continue
|
||||
if mountpoint -q "$mp" 2>/dev/null; then
|
||||
umount -l "$mp" 2>/dev/null && info " Unmounted raw: $mp" \
|
||||
|| warn " Could not unmount raw: $mp"
|
||||
fi
|
||||
done
|
||||
|
||||
# 3. Strip all .felhom-raw entries from fstab (both raw and bind lines)
|
||||
if [ -f /etc/fstab ] && grep -q '\.felhom-raw' /etc/fstab 2>/dev/null; then
|
||||
sed -i '\|\.felhom-raw|d' /etc/fstab && info " Removed .felhom-raw entries from /etc/fstab"
|
||||
fi
|
||||
|
||||
# 4. Remove directory — safe now that mounts are gone
|
||||
rm -rf /mnt/.felhom-raw && info " Removed: /mnt/.felhom-raw/"
|
||||
}
|
||||
|
||||
# --- Wipe Functions ---
|
||||
|
||||
do_soft_wipe() {
|
||||
@@ -336,6 +412,9 @@ do_full_wipe() {
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove stale scan dir (ephemeral DR staging — always safe to remove)
|
||||
cleanup_scan_dir
|
||||
|
||||
# Restart controller after all cleanup is done
|
||||
info "Restarting controller..."
|
||||
docker restart felhom-controller 2>/dev/null || warn "Could not restart controller"
|
||||
@@ -358,6 +437,10 @@ do_nuclear_wipe() {
|
||||
fi
|
||||
done
|
||||
|
||||
# Unmount raw helper mounts, strip fstab entries, remove dirs
|
||||
# (scan dir already removed by do_full_wipe above)
|
||||
cleanup_raw_mounts
|
||||
|
||||
# Remove all Docker data
|
||||
warn "Pruning all Docker data..."
|
||||
docker system prune -af --volumes 2>/dev/null || warn "Docker prune failed"
|
||||
|
||||
Reference in New Issue
Block a user