mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-09-14 06:02:35 +00:00
bash gpu detection fix & nvidia-smi hardening
- Fixed critical script termination on hybrid GPU systems (Intel+Nvidia). The `set -euo pipefail` header was causing immediate exit when `read` reached EOF with exit code 1, preventing further execution despite valid hardware detection. - Added `|| true` to the lspci processing loop in `modules/utils.sh`. This forces the while read condition to always return success (0), allowing clean loop termination and proper variable assignment for `HAS_NVIDIA=true` and `HAS_INTEL=true`. - Hardened nvidia-smi driver version query with timeout protection. Wrapped the command call with `|| true` to capture exit code 124 from `timeout`, preventing script abortion when GPU enters D3cold state or command fails. - Changes applied at line 204 (while read loop) and line 243 (nvidia-smi query). Both modifications ensure the main script continues execution after hardware detection completes, enabling full menu loading on dual-GPU laptops.
This commit is contained in:
+2
-2
@@ -201,7 +201,7 @@ detect_gpu() {
|
||||
local has_nvidia=false has_amd=false has_intel=false
|
||||
local desc_lines="" nvidia_dev_id="" intel_dev_id=""
|
||||
|
||||
while IFS= read -r line; do
|
||||
while IFS= read -r line || true; do
|
||||
local desc
|
||||
desc=$(echo "$line" | sed -E 's/.*: //; s/ *\(rev.*//')
|
||||
[ -n "$desc_lines" ] && desc_lines+=" + "
|
||||
@@ -240,7 +240,7 @@ detect_gpu() {
|
||||
|
||||
if [ "$GPU_TYPE" = "nvidia" ]; then
|
||||
local nv_ver
|
||||
nv_ver=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -1)
|
||||
nv_ver=$(timeout 3 nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -1) || true
|
||||
if [ -z "$nv_ver" ]; then
|
||||
nv_ver=$(dpkg -l nvidia-driver 2>/dev/null | awk '/^ii/ {print $3}' | sed 's/-.*//')
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user