Add screen and tmux fix menu exit behavior

This commit is contained in:
2026-10-01 20:35:53 +03:00
parent 56224b8e38
commit 1938705e00
4 changed files with 74 additions and 10 deletions
+31
View File
@@ -0,0 +1,31 @@
set default=0
set timeout=5
set timeout_style=menu
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
font=$prefix/unicode.pf2
fi
if loadfont $font ; then
set gfxmode=800x600
set gfxpayload=keep
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
else
set gfxmode=auto
insmod all_video
fi
insmod gfxterm
insmod png
source /boot/grub/theme.cfg
terminal_output gfxterm
insmod play
play 960 440 1 0 4 440 1
@@ -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
@@ -15,7 +15,9 @@ openssh-server
openbsd-inetd
parted
smartmontools
screen
sudo
tmux
util-linux
wireless-regdb
wpasupplicant