From 1938705e0047656143f2a85a8b1e4ee3ce57920f Mon Sep 17 00:00:00 2001 From: Tero Huttunen Date: Thu, 1 Oct 2026 20:35:53 +0300 Subject: [PATCH] Add screen and tmux fix menu exit behavior --- README.md | 6 ++- config/bootloaders/grub-pc/config.cfg | 31 +++++++++++++ .../includes.chroot/usr/local/sbin/ep-eraser | 45 +++++++++++++++---- config/package-lists/ep-eraser.list.chroot | 2 + 4 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 config/bootloaders/grub-pc/config.cfg diff --git a/README.md b/README.md index 8489497..ab362f1 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ sudo ./build.sh The output is `build/ep-eraser-amd64.hybrid.iso`. Write it to a USB drive with a tool such as Rufus or `dd`. Verify the output checksum before deployment. +The GRUB boot menu waits 5 seconds before starting the live system. + To build without installing packages on the host, use Docker from Linux or WSL: ```sh @@ -56,9 +58,9 @@ To build the OVA in Docker, use `docker run --rm -v "$PWD:/work" --entrypoint /w Boot the target machine from the image, inspect the disk list, and choose the exact device path. The program detects rotational media and presents the appropriate operation. Reboot after completion; do not remove the USB device until the result is shown. -Choose `nwipe` from the startup menu to use its interactive interface. Its PDF certificates are saved under `/var/log/ep-eraser/reports`; copy them to persistent storage before rebooting because the live system's filesystem is temporary. Press `c` in nwipe to edit certificate details such as company, customer, and host information. Those settings are also temporary unless included in the image. +Choose **Programs** from the startup menu to open `nwipe` or a root Bash shell. `tmux` and `screen` are installed for use from Bash. Nwipe's PDF certificates are saved under `/var/log/ep-eraser/reports`; copy them to persistent storage before rebooting because the live system's filesystem is temporary. Press `c` in nwipe to edit certificate details such as company, customer, and host information. Those settings are also temporary unless included in the image. -The supplied `config/includes.chroot/etc/nwipe/eternity-project-logo.svg` is converted to `logo.jpg` during image preparation for nwipe PDF certificates. The same logo is rendered as a colored startup screen above the tty1 menu. Nwipe is built from upstream v0.42 and uses `/etc/nwipe/logo.jpg` for PDF branding. You can include `/etc/nwipe/nwipe.conf` in `config/includes.chroot` to ship default certificate settings. +The supplied `config/includes.chroot/etc/nwipe/eternity-project-logo.svg` has a generated `logo.jpg` alongside it for nwipe PDF certificates. The same JPEG is rendered as a colored startup screen above the tty1 menu. Nwipe is built from upstream v0.42 and uses `/etc/nwipe/logo.jpg` for PDF branding. You can include `/etc/nwipe/nwipe.conf` in `config/includes.chroot` to ship default certificate settings. NetworkManager provides network connectivity; wired Ethernet uses DHCP automatically, and Wi-Fi can be configured with `nmcli device wifi list` followed by `nmcli device wifi connect "SSID" --ask`. The image starts SSH and Telnet servers for the `eraser` account with password `eperaser`; root SSH login is disabled. The account can run only the EP Eraser and nwipe programs through passwordless `sudo`, for example `sudo -n /usr/local/sbin/ep-eraser` or `sudo -n /usr/local/bin/nwipe`. diff --git a/config/bootloaders/grub-pc/config.cfg b/config/bootloaders/grub-pc/config.cfg new file mode 100644 index 0000000..1e6889f --- /dev/null +++ b/config/bootloaders/grub-pc/config.cfg @@ -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 \ No newline at end of file diff --git a/config/includes.chroot/usr/local/sbin/ep-eraser b/config/includes.chroot/usr/local/sbin/ep-eraser index 2732b7c..913c036 100644 --- a/config/includes.chroot/usr/local/sbin/ep-eraser +++ b/config/includes.chroot/usr/local/sbin/ep-eraser @@ -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 diff --git a/config/package-lists/ep-eraser.list.chroot b/config/package-lists/ep-eraser.list.chroot index 527049f..c954c71 100644 --- a/config/package-lists/ep-eraser.list.chroot +++ b/config/package-lists/ep-eraser.list.chroot @@ -15,7 +15,9 @@ openssh-server openbsd-inetd parted smartmontools +screen sudo +tmux util-linux wireless-regdb wpasupplicant