#!/bin/bash # Configuration REPORT_DIR="/var/log/nwipe_reports" WIPE_METHOD="dod3pass" PYTHON_MAP_SCRIPT="/usr/local/bin/drive_map" mkdir -p "$REPORT_DIR" # ANSI Escape codes for colored text GREEN='\033[0;32m' CYAN='\033[0;36m' YELLOW='\033[1;33m' NC='\033[0m' # No Color clear echo -e "${CYAN}=====================================================${NC}" echo -e "${CYAN} NWIPE MULTI-DRIVE CONTROL PANEL ${NC}" echo -e "${CYAN}=====================================================${NC}" # 1. Print the visual layout map to the terminal first if [ -f "$PYTHON_MAP_SCRIPT" ]; then python3 "$PYTHON_MAP_SCRIPT" else echo "Warning: Python mapping script not found at $PYTHON_MAP_SCRIPT" fi # 2. Safely isolate the boot/OS disk OS_DISK=$(lsblk -no PKNAME $(findmnt -no SOURCE /)) DRIVES=$(lsblk -dno NAME,TYPE | awk '$2=="disk" {print $1}') # Associative arrays to track state declare -A DRIVE_BAYS declare -A DEPLOYED_DRIVES echo -e "${YELLOW}Initializing independent background wipe tasks...${NC}" for DISK in $DRIVES; do if [ "$DISK" = "$OS_DISK" ]; then continue fi # Fetch 1-indexed physical bay (e.g., R1-C3) BAY_LOC=$(python3 "$PYTHON_MAP_SCRIPT" --mapping | grep "^${DISK}:" | cut -d':' -f2) if [ -z "$BAY_LOC" ]; then BAY_LOC="Unknown" fi # Store bay mapping for reporting DRIVE_BAYS[$DISK]=$BAY_LOC # Unique name for this drive's hidden tmux session SESSION_NAME="hidden-wipe-${DISK}" # Force kill any stale sessions for this disk if they exist tmux kill-session -t "$SESSION_NAME" 2>/dev/null # Command to run nwipe NWIPE_CMD="sudo nwipe --autonuke --nowait --method=$WIPE_METHOD --PDFreportpath=$REPORT_DIR /dev/$DISK" # Spawn the nwipe task completely hidden inside a detached tmux session tmux new-session -d -s "$SESSION_NAME" "$NWIPE_CMD" # Track that this drive is actively running DEPLOYED_DRIVES[$DISK]="RUNNING" echo " -> Drive /dev/$DISK ($BAY_LOC) started in background." done echo -e "\n${YELLOW}Monitoring drive progress. Do not close this terminal.${NC}" echo -e "-----------------------------------------------------\n" # 3. Live Monitoring Loop while [ ${#DEPLOYED_DRIVES[@]} -gt 0 ]; do sleep 3 # Check status every 3 seconds for DISK in "${!DEPLOYED_DRIVES[@]}"; do SESSION_NAME="hidden-wipe-${DISK}" BAY=${DRIVE_BAYS[$DISK]} # Check if the background tmux session has died (meaning nwipe finished) if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then # Format the output to fit your non-programmer technician layout # Translates internal R1-C1 to user friendly R1:C1 format DISPLAY_BAY=$(echo "$BAY" | sed 's/-/:/') echo -e "${GREEN}[SUCCESS] Drive $DISPLAY_BAY [/dev/$DISK] wiped successfully. PDF certificate generated.${NC}" # Remove from tracking list so we stop monitoring it unset DEPLOYED_DRIVES[$DISK] fi done done echo -e "\n${CYAN}=====================================================${NC}" echo -e "${GREEN}ALL ACTIVE WIPING TASKS COMPLETED SUCCESSFULLY!${NC}" echo -e "${CYAN}=====================================================${NC}\n" echo -e "${YELLOW}Run xfrlogs when ready to transfer logs to USB.${NC}"