From ad3c84d03a53095a7963ffcc6396b43fe7dd3810 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Sun, 22 Feb 2026 12:10:34 +0100 Subject: [PATCH] fix(felhom-wipe): detect drives via .felhom-infra-backup, clean empty /mnt/ dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- scripts/felhom-wipe.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/felhom-wipe.sh b/scripts/felhom-wipe.sh index 90b32cf..1b14e55 100644 --- a/scripts/felhom-wipe.sh +++ b/scripts/felhom-wipe.sh @@ -121,9 +121,11 @@ except: pass " 2>/dev/null || true) 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 - [ -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 for sp in "${STORAGE_PATHS[@]:-}"; do [ "$sp" = "${d%/}" ] && already=true && break @@ -248,7 +250,15 @@ print_plan() { echo -e " ${RED}DELETE${NC} Traefik container" 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)" + 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 echo -e " ${RED}UNMOUNT+DELETE${NC} /mnt/.felhom-raw/ (raw helper mounts + fstab entries)" # 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 "$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 "" info "Nuclear wipe complete." echo -e "${CYAN}To redeploy, run:${NC}"