mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-09-14 06:02:35 +00:00
dual-gpu hardening & wireless robustness
- Protected apt repository writes across modules/repos.sh by adding `|| return 1` to `_write_deb822()` and `_write_classic()`, ensuring script continuation on failure instead of aborting under set -e. - Added idempotent backup restoration in restore_previous_repos() with `sudo cp ... || true` and `sudo rm ... || true` to prevent fatal errors during repository recovery operations. - Implemented rollback mechanism in migrate_to_branch() by wrapping _write_branch_sources() in a conditional check, restoring backup on failure and returning error code 1. - Hardened firmware installation flow in modules/firmware.sh with `|| true` guards on all apt commands (broadcom-sta-dkms, network firmware packages, backports/stable paths), preventing set -e aborts during package management. - Secured modprobe operations by adding `|| true` to wl module loading and blacklist file writes, ensuring wireless driver installation proceeds even if kernel module operations fail. - Added GPU tools installation protection in _helpers.sh with `|| true` guard on vainfo command execution after nvtop installation completes successfully. - Fixed NVIDIA Wayland configuration in modules/gpu/nvidia.sh by adding `|| return 1` to nvidia-wayland.conf tee operation, preventing silent failures when writing modprobe configuration files. - Implemented network warning notification before Broadcom wireless module removal to alert users of potential SSH disconnection during WiFi driver transitions. - Added broadcom blacklist file protection with `|| true` guard on modprobe.d/blacklist-broadcom.conf writes to prevent script termination on filesystem errors. - Standardized error handling patterns across all firmware and GPU modules, replacing direct command execution with conditional wrappers that maintain script continuity under failure conditions.
This commit is contained in:
@@ -64,7 +64,7 @@ _write_deb822_branch() {
|
||||
fi
|
||||
|
||||
sudo mkdir -p /etc/apt/sources.list.d
|
||||
echo -e "$main_content" | sudo tee "$main_file" > /dev/null
|
||||
echo -e "$main_content" | sudo tee "$main_file" >/dev/null
|
||||
echo "Wrote $main_file"
|
||||
}
|
||||
|
||||
@@ -80,14 +80,14 @@ _write_classic_branch() {
|
||||
main_content+="deb https://security.debian.org/debian-security ${target}-security main contrib non-free non-free-firmware\n"
|
||||
fi
|
||||
|
||||
echo -e "$main_content" | sudo tee "$main_file" > /dev/null
|
||||
echo -e "$main_content" | sudo tee "$main_file" >/dev/null
|
||||
echo "Wrote $main_file"
|
||||
}
|
||||
|
||||
_branch_migration() {
|
||||
# ── Screen 1: Risk warning ──
|
||||
_msg_red "WARNING: Branch Migration" \
|
||||
"Migrating from Debian Stable to Testing or SID is a\n\
|
||||
"Migrating from Debian Stable to Testing or SID is a\n\
|
||||
MAJOR change and CAN make your system UNBOOTABLE.\n\n\
|
||||
Risks include:\n\
|
||||
• NVIDIA / DKMS drivers may break\n\
|
||||
@@ -125,7 +125,10 @@ so you can restore if things go wrong." 16 70
|
||||
branch=$(_inputbox "Target Branch" \
|
||||
"Type exactly TESTING or SID (case-sensitive):" 10 60 "")
|
||||
|
||||
[ -z "$branch" ] && { echo "Migration cancelled."; return; }
|
||||
[ -z "$branch" ] && {
|
||||
echo "Migration cancelled."
|
||||
return
|
||||
}
|
||||
|
||||
if [ "$branch" != "TESTING" ] && [ "$branch" != "SID" ]; then
|
||||
_msg "Invalid Branch" "You typed: $branch\n\nExpected: TESTING or SID (exact, case-sensitive).\nAborting." 10 60
|
||||
@@ -155,7 +158,11 @@ so you can restore if things go wrong." 16 70
|
||||
[ -f /etc/apt/sources.list ] && sudo rm -f /etc/apt/sources.list
|
||||
|
||||
# 4d. Write new sources
|
||||
_write_branch_sources "$target"
|
||||
if ! _write_branch_sources "$target"; then
|
||||
echo -e "${RED}[-]${NC} Failed to write new sources. Restoring backup..."
|
||||
_restore_backup || true
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 4e. SID guardrails: install bug alerts before upgrade
|
||||
if [ "$target" = "sid" ]; then
|
||||
@@ -170,7 +177,7 @@ so you can restore if things go wrong." 16 70
|
||||
echo -e "${RED}apt update failed. Restoring backup...${NC}"
|
||||
_restore_backup
|
||||
_msg_red "Migration Failed" \
|
||||
"apt update failed. Backup has been restored from:\n\
|
||||
"apt update failed. Backup has been restored from:\n\
|
||||
$_MIGRATE_BACKUP\n\n\
|
||||
Your system should be back to its previous state.\n\
|
||||
Run 'sudo apt update' manually to verify." 12 70
|
||||
@@ -193,7 +200,7 @@ Run 'sudo apt update' manually to verify." 12 70
|
||||
|
||||
# ── Screen 5: Reboot reminder ──
|
||||
_msg "Migration Complete" \
|
||||
"System has been migrated to ${target}.\n\n\
|
||||
"System has been migrated to ${target}.\n\n\
|
||||
Backup saved at:\n $_MIGRATE_BACKUP\n\n\
|
||||
REBOOT your system.\nIf it fails to boot, restore the backup manually:\n\
|
||||
sudo tar xzf $_MIGRATE_BACKUP -C /\n sudo apt update\n sudo apt upgrade" 16 70
|
||||
|
||||
Reference in New Issue
Block a user