mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-09-14 06:02:35 +00:00
fix harden hardware detection D3cold freezes
Fixes a critical startup crash on hybrid graphics laptops (e.g., Intel + Nvidia) running fresh Debian installs without proprietary drivers.
When the secondary GPU enters D3cold power state, kernel-level I/O operations (like `lspci` or reading `/sys/block/`) hang in Uninterruptible Sleep (State D), ignoring standard kill signals and freezing the terminal. Combined with `set -euo pipefail`, these hangs made the script silently fail or enter infinite loops.
Changes:
- Timeout Wrappers: Wrapped all hardware probing commands (`lspci`, `lsblk`, `cat /sys/...`, `ip`, `iwgetid`, `pw-cli`) with `timeout 2` to force-continue if the kernel blocks.
- Pipeline Safety: Added `|| true` to `nvidia-smi` and `dpkg` fallback queries to prevent `pipefail` from killing the script when drivers are missing.
- Loop Hardening: Fixed an infinite loop in `detect_gpu()` where empty `lspci` outputs caused by timeouts would loop forever by adding `[[ -z "$line" ]] && continue`.
- TUI Fallbacks: Added default values for `${LINES:-24}` and `${COLUMNS:-80}` to prevent `set -u` from crashing the `whiptail` menu in restricted shell environments.
This commit is contained in:
@@ -225,7 +225,7 @@ _cat_general() {
|
||||
fi
|
||||
;;
|
||||
nvme-cli)
|
||||
if ! lsblk -d -o TRAN 2>/dev/null | grep -q "^nvme$"; then
|
||||
if ! timeout 2 lsblk -d -o TRAN 2>/dev/null | grep -q "^nvme$"; then
|
||||
echo "No NVMe controller detected. Skipping."
|
||||
continue
|
||||
fi
|
||||
@@ -235,7 +235,7 @@ _cat_general() {
|
||||
local nvme_devs=()
|
||||
while read -r dev; do
|
||||
nvme_devs+=("$dev")
|
||||
done < <(lsblk -d -o NAME,TRAN 2>/dev/null | awk '$2 == "nvme" {print $1}')
|
||||
done < <(timeout 2 lsblk -d -o NAME,TRAN 2>/dev/null | awk '$2 == "nvme" {print $1}')
|
||||
if [ ${#nvme_devs[@]} -eq 0 ]; then
|
||||
echo "No NVMe block devices found for health check."
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user