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:
+4
-4
@@ -112,7 +112,7 @@ _show_sysinfo() {
|
||||
lo|docker*|veth*|br-*|virbr*|tun*|tap*|bond*) continue ;;
|
||||
esac
|
||||
|
||||
ip4=$(ip -4 -o addr show "$iface" 2>/dev/null | awk '{print $4}')
|
||||
ip4=$(timeout 2 ip -4 -o addr show "$iface" 2>/dev/null | awk '{print $4}')
|
||||
|
||||
# Determine type by PCI class (most reliable)
|
||||
local pci_class=""
|
||||
@@ -129,7 +129,7 @@ _show_sysinfo() {
|
||||
desc="${wifi_descs[0]:-Unknown WiFi chipset}"
|
||||
shown_wifi_descs+=("${wifi_descs[0]}")
|
||||
ssid=""
|
||||
[ "$state" = "UP" ] && ssid=$(iwgetid -r "$iface" 2>/dev/null || true)
|
||||
[ "$state" = "UP" ] && ssid=$(timeout 2 iwgetid -r "$iface" 2>/dev/null || true)
|
||||
;;
|
||||
*)
|
||||
# Fallback: classify by interface name pattern
|
||||
@@ -139,7 +139,7 @@ _show_sysinfo() {
|
||||
desc="${wifi_descs[0]:-Unknown WiFi chipset}"
|
||||
shown_wifi_descs+=("${wifi_descs[0]}")
|
||||
ssid=""
|
||||
[ "$state" = "UP" ] && ssid=$(iwgetid -r "$iface" 2>/dev/null || true)
|
||||
[ "$state" = "UP" ] && ssid=$(timeout 2 iwgetid -r "$iface" 2>/dev/null || true)
|
||||
;;
|
||||
eth*|enp*|ens*|enx*|eno*)
|
||||
has_eth=true
|
||||
@@ -163,7 +163,7 @@ _show_sysinfo() {
|
||||
else
|
||||
msg+="${iface}: ${desc}\n ↓\n"
|
||||
fi
|
||||
done < <(ip -o link show 2>/dev/null)
|
||||
done < <(timeout 2 ip -o link show 2>/dev/null)
|
||||
fi
|
||||
|
||||
# ── 5. Show chipsets without an active interface ──
|
||||
|
||||
Reference in New Issue
Block a user