fix(felhom-wipe): detect drives via .felhom-infra-backup, clean empty /mnt/ dirs

- detect_storage_paths(): also matches drives that have .felhom-infra-backup/
  so sys_drive-style mounts (internal SSD partitions with DR markers) are
  detected even when settings.json is gone and felhom-data/ doesn't exist.
- do_nuclear_wipe(): rmdir all empty /mnt/*/ dirs at end of nuclear wipe
  to clean up leftover mount point directories (e.g. /mnt/hdd_1 when the
  raw mount was already cleaned by a prior wipe run). rmdir is safe — it
  refuses non-empty directories.
- print_plan(): show per-drive .felhom-infra-backup entries for nuclear level.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-22 12:10:34 +01:00
parent 5c455755a5
commit ad3c84d03a
+21 -3
View File
@@ -121,9 +121,11 @@ except: pass
" 2>/dev/null || true) " 2>/dev/null || true)
fi fi
# Also scan /mnt/* for felhom-managed dirs not in registry # Also scan /mnt/* for felhom-managed dirs not in registry.
# Detect by presence of felhom-data/, legacy appdata/backups/, or .felhom-infra-backup/
for d in /mnt/*/; do for d in /mnt/*/; do
[ -d "${d}felhom-data" ] || [ -d "${d}appdata" ] || [ -d "${d}backups" ] || continue [ -d "${d}felhom-data" ] || [ -d "${d}appdata" ] || [ -d "${d}backups" ] \
|| [ -d "${d}.felhom-infra-backup" ] || continue
local already=false local already=false
for sp in "${STORAGE_PATHS[@]:-}"; do for sp in "${STORAGE_PATHS[@]:-}"; do
[ "$sp" = "${d%/}" ] && already=true && break [ "$sp" = "${d%/}" ] && already=true && break
@@ -248,7 +250,15 @@ print_plan() {
echo -e " ${RED}DELETE${NC} Traefik container" echo -e " ${RED}DELETE${NC} Traefik container"
echo -e " ${RED}DELETE${NC} Cloudflared container" echo -e " ${RED}DELETE${NC} Cloudflared container"
echo -e " ${RED}DELETE${NC} Portainer container + volume" echo -e " ${RED}DELETE${NC} Portainer container + volume"
echo -e " ${RED}DELETE${NC} .felhom-infra-backup/ (DR markers on all drives)" echo -e " ${RED}DELETE${NC} .felhom-infra-backup/ (DR markers on detected drives):"
local dr_found=false
for sp in "${STORAGE_PATHS[@]:-}"; do
if [ -d "$sp/.felhom-infra-backup" ]; then
echo -e " ${RED}DELETE${NC} $sp/.felhom-infra-backup/"
dr_found=true
fi
done
$dr_found || echo -e " ${GREEN}(none found)${NC}"
if [ -d /mnt/.felhom-raw ]; then if [ -d /mnt/.felhom-raw ]; then
echo -e " ${RED}UNMOUNT+DELETE${NC} /mnt/.felhom-raw/ (raw helper mounts + fstab entries)" echo -e " ${RED}UNMOUNT+DELETE${NC} /mnt/.felhom-raw/ (raw helper mounts + fstab entries)"
# Show each raw mount and its bind target # Show each raw mount and its bind target
@@ -463,6 +473,14 @@ do_nuclear_wipe() {
rm -rf "$infra_root/cloudflared" && info " Removed: $infra_root/cloudflared/" rm -rf "$infra_root/cloudflared" && info " Removed: $infra_root/cloudflared/"
rm -rf "$STACKS_DIR" && info " Removed: $STACKS_DIR/" rm -rf "$STACKS_DIR" && info " Removed: $STACKS_DIR/"
# Remove any leftover empty mount point dirs under /mnt/ (e.g. /mnt/hdd_1 after
# the bind mount was already cleaned by a prior wipe run). rmdir is safe: it
# refuses to remove non-empty directories, so user data is never at risk.
for mp in /mnt/*/; do
[ -d "$mp" ] || continue
rmdir "$mp" 2>/dev/null && info " Removed empty mount point: $mp" || true
done
echo "" echo ""
info "Nuclear wipe complete." info "Nuclear wipe complete."
echo -e "${CYAN}To redeploy, run:${NC}" echo -e "${CYAN}To redeploy, run:${NC}"