Build fixes

This commit is contained in:
2026-10-01 15:00:43 +03:00
parent b3bbf8c5aa
commit 68709879eb
302 changed files with 154 additions and 1276614 deletions
@@ -3,7 +3,7 @@ set -eu
version=0.42
archive_sha256=0E38474495CC6C86043A1DE0460CF0DC009AD68E079EE23D71569E80E55CD2E6
build_packages="autoconf automake autopoint build-essential gettext libconfig++-dev libconfig-dev libncurses-dev libparted-dev libtool libuuid-dev pkg-config wget"
build_packages="autoconf automake autopoint build-essential gettext libconfig++-dev libconfig-dev libncurses-dev libparted-dev libtool pkg-config uuid-dev wget"
work_dir=$(mktemp -d)
cleanup() {
@@ -2,7 +2,9 @@
set -eu
chmod 0755 /usr/local/sbin/ep-eraser-remote-setup
chmod 0750 /etc/sudoers.d
chmod 0440 /etc/sudoers.d/ep-eraser
visudo --check --file=/etc/sudoers
install -d -m 0755 /run/sshd
sshd -t
systemctl enable ep-eraser-remote-access.service ssh.service openbsd-inetd.service
systemctl enable ep-eraser-remote-access.service ssh.service inetd.service
+127 -127
View File
@@ -1,128 +1,128 @@
#!/usr/bin/env bash
set -Eeuo pipefail
LOG=/var/log/ep-eraser.log
exec > >(tee -a "$LOG") 2>&1
die() { printf '\nERROR: %s\n' "$*" >&2; read -r -p 'Press Enter to return to the menu...' _; }
mounted() {
findmnt -rn -S "$1" >/dev/null 2>&1 && return 0
lsblk -nrpo NAME,MOUNTPOINTS "$1" | awk 'NF > 1 && $2 != "" { found=1 } END { exit !found }'
}
is_live_device() {
local live parent
live=$(findmnt -rn -o SOURCE /run/live/medium 2>/dev/null || true)
[ -n "$live" ] || return 1
parent=$(lsblk -dnro PKNAME "$live" 2>/dev/null || true)
[ -n "$parent" ] && [ "$1" = "/dev/$parent" ]
}
disk_info() {
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL,TRAN | awk '$2 == "disk" { print }'
}
choose_disk() {
mapfile -t disks < <(lsblk -dnpo NAME,TYPE | awk '$2 == "disk" { print $1 }')
[ "${#disks[@]}" -gt 0 ] || { die 'No whole disks were detected.'; return 1; }
printf '\nDetected disks:\n\n'
printf '%-4s %-18s %-10s %-24s %-16s %s\n' '#' DEVICE SIZE MODEL SERIAL TRAN
disk_info | nl -w2 -s' '
printf '\nEnter the number shown above, or q to quit: '
read -r choice
[ "$choice" = q ] && exit 0
[[ "$choice" =~ ^[0-9]+$ ]] || { die 'Invalid selection.'; return 1; }
target=${disks[$((choice - 1))]:-}
[ -n "$target" ] || { die 'Invalid selection.'; return 1; }
}
validate_target() {
[ -b "$target" ] || { die 'Selected path is not a block device.'; return 1; }
[ "$(lsblk -dnro TYPE "$target")" = disk ] || { die 'Only whole disks may be erased.'; return 1; }
[ "$(lsblk -dnro RO "$target")" = 0 ] || { die 'The disk is read-only.'; return 1; }
mounted "$target" && { die 'The disk or one of its partitions is mounted.'; return 1; }
is_live_device "$target" && { die 'The live boot device cannot be erased.'; return 1; }
}
confirm() {
local info
info=$(lsblk -dnpo NAME,SIZE,MODEL,SERIAL "$target")
printf '\nTARGET: %s\n%s\n\nThis permanently destroys all data. Type ERASE to continue: ' "$target" "$info"
read -r answer
[ "$answer" = ERASE ] || { printf 'Cancelled.\n'; return 1; }
}
erase_ssd() {
printf '\nSSD/NVMe erase options:\n1) Secure discard (blkdiscard --secure)\n2) NVMe sanitize (NVMe only)\n3) Cancel\nChoose: '
read -r method
case "$method" in
1)
blkdiscard --secure --force "$target" || { die 'Secure discard failed; no data was overwritten.'; return 1; }
;;
2)
[[ "$target" == /dev/nvme*n* ]] || { die 'NVMe sanitize requires an NVMe namespace.'; return 1; }
nvme sanitize "$target" -a 2 || { die 'NVMe sanitize failed.'; return 1; }
nvme sanitize-log "$target" -H || true
;;
*) printf 'Cancelled.\n'; return 1 ;;
esac
}
erase_hdd() {
printf '\nHDD erase uses three random overwrite passes plus a zero pass. Continue? [yes/no]: '
read -r answer
[ "$answer" = yes ] || { printf 'Cancelled.\n'; return 1; }
shred --verbose --iterations=3 --zero --force "$target"
}
verify() {
printf '\nFinal device state:\n'
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL "$target"
printf 'Erase command completed. Verification is limited to command/device status.\n'
}
run_ep_eraser() {
while true; do
choose_disk || continue
validate_target || continue
rotational=$(lsblk -dnro ROTA "$target")
if [ "$rotational" = 1 ]; then
operation=HDD
else
operation=SSD/NVMe
fi
printf '\nDetected media type: %s\n' "$operation"
confirm || continue
if [ "$operation" = HDD ]; then erase_hdd; else erase_ssd; fi
verify
printf '\nPress Enter to return to the disk menu, or type q to quit: '
read -r answer
[ "$answer" = q ] && exit 0
done
}
run_nwipe() {
local report_dir=/var/log/ep-eraser/reports
mkdir -p /etc/nwipe
mkdir -p "$report_dir"
cd /etc/nwipe
nwipe --PDFreportpath="$report_dir" </dev/tty >/dev/tty 2>&1
}
main() {
[ "$(id -u)" -eq 0 ] || { echo 'This tool must run as root.' >&2; exit 1; }
while true; do
printf '\nEP ERASER - disk sanitization tools\n===================================\n'
printf '1) EP Eraser (device-specific)\n2) nwipe (interactive)\nq) Quit\nChoose a tool: '
read -r choice
case "$choice" in
1) run_ep_eraser ;;
2) run_nwipe ;;
q) exit 0 ;;
*) die 'Invalid selection.' ;;
esac
done
}
#!/usr/bin/env bash
set -Eeuo pipefail
LOG=/var/log/ep-eraser.log
exec > >(tee -a "$LOG") 2>&1
die() { printf '\nERROR: %s\n' "$*" >&2; read -r -p 'Press Enter to return to the menu...' _; }
mounted() {
findmnt -rn -S "$1" >/dev/null 2>&1 && return 0
lsblk -nrpo NAME,MOUNTPOINTS "$1" | awk 'NF > 1 && $2 != "" { found=1 } END { exit !found }'
}
is_live_device() {
local live parent
live=$(findmnt -rn -o SOURCE /run/live/medium 2>/dev/null || true)
[ -n "$live" ] || return 1
parent=$(lsblk -dnro PKNAME "$live" 2>/dev/null || true)
[ -n "$parent" ] && [ "$1" = "/dev/$parent" ]
}
disk_info() {
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL,TRAN | awk '$2 == "disk" { print }'
}
choose_disk() {
mapfile -t disks < <(lsblk -dnpo NAME,TYPE | awk '$2 == "disk" { print $1 }')
[ "${#disks[@]}" -gt 0 ] || { die 'No whole disks were detected.'; return 1; }
printf '\nDetected disks:\n\n'
printf '%-4s %-18s %-10s %-24s %-16s %s\n' '#' DEVICE SIZE MODEL SERIAL TRAN
disk_info | nl -w2 -s' '
printf '\nEnter the number shown above, or q to quit: '
read -r choice
[ "$choice" = q ] && exit 0
[[ "$choice" =~ ^[0-9]+$ ]] || { die 'Invalid selection.'; return 1; }
target=${disks[$((choice - 1))]:-}
[ -n "$target" ] || { die 'Invalid selection.'; return 1; }
}
validate_target() {
[ -b "$target" ] || { die 'Selected path is not a block device.'; return 1; }
[ "$(lsblk -dnro TYPE "$target")" = disk ] || { die 'Only whole disks may be erased.'; return 1; }
[ "$(lsblk -dnro RO "$target")" = 0 ] || { die 'The disk is read-only.'; return 1; }
mounted "$target" && { die 'The disk or one of its partitions is mounted.'; return 1; }
is_live_device "$target" && { die 'The live boot device cannot be erased.'; return 1; }
}
confirm() {
local info
info=$(lsblk -dnpo NAME,SIZE,MODEL,SERIAL "$target")
printf '\nTARGET: %s\n%s\n\nThis permanently destroys all data. Type ERASE to continue: ' "$target" "$info"
read -r answer
[ "$answer" = ERASE ] || { printf 'Cancelled.\n'; return 1; }
}
erase_ssd() {
printf '\nSSD/NVMe erase options:\n1) Secure discard (blkdiscard --secure)\n2) NVMe sanitize (NVMe only)\n3) Cancel\nChoose: '
read -r method
case "$method" in
1)
blkdiscard --secure --force "$target" || { die 'Secure discard failed; no data was overwritten.'; return 1; }
;;
2)
[[ "$target" == /dev/nvme*n* ]] || { die 'NVMe sanitize requires an NVMe namespace.'; return 1; }
nvme sanitize "$target" -a 2 || { die 'NVMe sanitize failed.'; return 1; }
nvme sanitize-log "$target" -H || true
;;
*) printf 'Cancelled.\n'; return 1 ;;
esac
}
erase_hdd() {
printf '\nHDD erase uses three random overwrite passes plus a zero pass. Continue? [yes/no]: '
read -r answer
[ "$answer" = yes ] || { printf 'Cancelled.\n'; return 1; }
shred --verbose --iterations=3 --zero --force "$target"
}
verify() {
printf '\nFinal device state:\n'
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL "$target"
printf 'Erase command completed. Verification is limited to command/device status.\n'
}
run_ep_eraser() {
while true; do
choose_disk || continue
validate_target || continue
rotational=$(lsblk -dnro ROTA "$target")
if [ "$rotational" = 1 ]; then
operation=HDD
else
operation=SSD/NVMe
fi
printf '\nDetected media type: %s\n' "$operation"
confirm || continue
if [ "$operation" = HDD ]; then erase_hdd; else erase_ssd; fi
verify
printf '\nPress Enter to return to the disk menu, or type q to quit: '
read -r answer
[ "$answer" = q ] && exit 0
done
}
run_nwipe() {
local report_dir=/var/log/ep-eraser/reports
mkdir -p /etc/nwipe
mkdir -p "$report_dir"
cd /etc/nwipe
nwipe --PDFreportpath="$report_dir" </dev/tty >/dev/tty 2>&1
}
main() {
[ "$(id -u)" -eq 0 ] || { echo 'This tool must run as root.' >&2; exit 1; }
while true; do
printf '\nEP ERASER - disk sanitization tools\n===================================\n'
printf '1) EP Eraser (device-specific)\n2) nwipe (interactive)\nq) Quit\nChoose a tool: '
read -r choice
case "$choice" in
1) run_ep_eraser ;;
2) run_nwipe ;;
q) exit 0 ;;
*) die 'Invalid selection.' ;;
esac
done
}
main "$@"
@@ -1,4 +1,4 @@
#!/bin/sh
set -eu
#!/bin/sh
set -eu
printf '%s\n' 'eraser:eperaser' | chpasswd
+20 -20
View File
@@ -1,21 +1,21 @@
bash
coreutils
hdparm
inetutils-telnet
inetutils-telnetd
iproute2
libconfig11
libncurses6
libparted2t64
network-manager
nvme-cli
openssh-client
openssh-server
openbsd-inetd
parted
smartmontools
sudo
util-linux
wireless-regdb
wpasupplicant
bash
coreutils
hdparm
inetutils-telnet
inetutils-telnetd
iproute2
libconfig11
libncurses6
libparted2t64
network-manager
nvme-cli
openssh-client
openssh-server
openbsd-inetd
parted
smartmontools
sudo
util-linux
wireless-regdb
wpasupplicant
whiptail