Add screen and tmux fix menu exit behavior
This commit is contained in:
@@ -31,7 +31,7 @@ choose_disk() {
|
||||
disk_info | nl -w2 -s' '
|
||||
printf '\nEnter the number shown above, or q to quit: '
|
||||
read -r choice
|
||||
[ "$choice" = q ] && exit 0
|
||||
[ "$choice" = q ] && return 2
|
||||
[[ "$choice" =~ ^[0-9]+$ ]] || { die 'Invalid selection.'; return 1; }
|
||||
target=${disks[$((choice - 1))]:-}
|
||||
[ -n "$target" ] || { die 'Invalid selection.'; return 1; }
|
||||
@@ -83,8 +83,15 @@ verify() {
|
||||
}
|
||||
|
||||
run_ep_eraser() {
|
||||
local selection_status
|
||||
while true; do
|
||||
choose_disk || continue
|
||||
if choose_disk; then
|
||||
:
|
||||
else
|
||||
selection_status=$?
|
||||
[ "$selection_status" -eq 2 ] && return 0
|
||||
continue
|
||||
fi
|
||||
validate_target || continue
|
||||
rotational=$(lsblk -dnro ROTA "$target")
|
||||
if [ "$rotational" = 1 ]; then
|
||||
@@ -94,11 +101,19 @@ run_ep_eraser() {
|
||||
fi
|
||||
printf '\nDetected media type: %s\n' "$operation"
|
||||
confirm || continue
|
||||
if [ "$operation" = HDD ]; then erase_hdd; else erase_ssd; fi
|
||||
if [ "$operation" = HDD ]; then
|
||||
if ! erase_hdd; then
|
||||
printf '\nHDD erase failed or was interrupted. Returning to the disk menu.\n'
|
||||
continue
|
||||
fi
|
||||
elif ! erase_ssd; then
|
||||
printf '\nSSD/NVMe erase failed or was interrupted. Returning to the disk menu.\n'
|
||||
continue
|
||||
fi
|
||||
verify
|
||||
printf '\nPress Enter to return to the disk menu, or type q to quit: '
|
||||
read -r answer
|
||||
[ "$answer" = q ] && exit 0
|
||||
[ "$answer" = q ] && return 0
|
||||
done
|
||||
}
|
||||
|
||||
@@ -137,6 +152,21 @@ run_bash() {
|
||||
fi
|
||||
}
|
||||
|
||||
run_programs() {
|
||||
while true; do
|
||||
printf '\nPrograms\n========\n'
|
||||
printf '1) nwipe\n2) Bash shell (root)\nb) Back\nq) Quit\nChoose a program: '
|
||||
read -r choice
|
||||
case "$choice" in
|
||||
1) run_nwipe ;;
|
||||
2) run_bash ;;
|
||||
b) return ;;
|
||||
q) return ;;
|
||||
*) die 'Invalid selection.' ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
show_startup_screen() {
|
||||
if command -v chafa >/dev/null 2>&1 && [ -f /etc/nwipe/logo.jpg ]; then
|
||||
chafa --format symbols --symbols block --colors 16 --size 44x11 \
|
||||
@@ -149,13 +179,12 @@ main() {
|
||||
[ "$(id -u)" -eq 0 ] || { echo 'This tool must run as root.' >&2; exit 1; }
|
||||
show_startup_screen
|
||||
while true; do
|
||||
printf '\nEP ERASER - disk sanitization tools\n===================================\n'
|
||||
printf '1) EP Eraser (device-specific)\n2) nwipe (interactive)\n3) Bash shell (root)\nq) Quit\nChoose a tool: '
|
||||
printf '\nEP ERASER\n=========\n'
|
||||
printf '1) EP Eraser\n2) Programs\nq) Quit\nChoose: '
|
||||
read -r choice
|
||||
case "$choice" in
|
||||
1) run_ep_eraser ;;
|
||||
2) run_nwipe ;;
|
||||
3) run_bash ;;
|
||||
2) run_programs ;;
|
||||
q) exit 0 ;;
|
||||
*) die 'Invalid selection.' ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user