From 762285f993af5759731231ad719442c60259333a Mon Sep 17 00:00:00 2001 From: stornic56 <71296607+stornic56@users.noreply.github.com> Date: Sat, 25 Jul 2026 22:53:18 -0500 Subject: [PATCH] fix script -fix script and nvidia-smi --- modules/firmware.sh | 4 ++-- modules/gpu.sh | 4 ++-- modules/gpu/_helpers.sh | 12 ++++++------ modules/sysinfo.sh | 10 +++++----- modules/utils.sh | 15 ++++++++------- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/modules/firmware.sh b/modules/firmware.sh index 6ad210a..df707bd 100644 --- a/modules/firmware.sh +++ b/modules/firmware.sh @@ -17,7 +17,7 @@ _detect_all_network_devices() { PCI_NET_DEVS=() while IFS= read -r line; do PCI_NET_DEVS+=("$line") - done < <(lspci -nn 2>/dev/null | grep -iE 'network controller|ethernet controller' || true) + done < <(timeout 2 lspci -nn 2>/dev/null | grep -iE 'network controller|ethernet controller' || true) USB_WIFI_DEVS=() while IFS= read -r line; do @@ -29,7 +29,7 @@ _detect_all_network_devices() { PCI_BT_DEVS=() while IFS= read -r line; do PCI_BT_DEVS+=("$line") - done < <(lspci -nn 2>/dev/null | grep -i 'Bluetooth controller' || true) + done < <(timeout 2 lspci -nn 2>/dev/null | grep -i 'Bluetooth controller' || true) USB_BT_DEVS=() while IFS= read -r line; do diff --git a/modules/gpu.sh b/modules/gpu.sh index 2d5f55c..cc576f9 100644 --- a/modules/gpu.sh +++ b/modules/gpu.sh @@ -61,7 +61,7 @@ _install_amd_intel_stack() { local desc desc=$(echo "$gpu_line" | sed -E 's/.*: //; s/ *\(rev.*//') plan+=" GPU ${gpu_count}: ${desc}\n" - done < <(lspci -nn | grep -E "VGA|3D" || true) + done < <(timeout 2 lspci -nn | grep -E "VGA|3D" || true) plan+="\nPlanned components:\n" if $HAS_INTEL; then local _gen; _gen=$(get_intel_generation) @@ -165,7 +165,7 @@ _install_nvidia_stack() { local desc desc=$(echo "$gpu_line" | sed -E 's/.*: //; s/ *\(rev.*//') plan+=" GPU ${gpu_count}: ${desc}\n" - done < <(lspci -nn | grep -E "VGA|3D" || true) + done < <(timeout 2 lspci -nn | grep -E "VGA|3D" || true) plan+="\nPlanned:\n [+] NVIDIA proprietary driver" _msg "NVIDIA Stack — Plan" "$plan" 14 65 diff --git a/modules/gpu/_helpers.sh b/modules/gpu/_helpers.sh index 379d8a7..743ac2a 100644 --- a/modules/gpu/_helpers.sh +++ b/modules/gpu/_helpers.sh @@ -3,7 +3,7 @@ is_nvidia_kepler() { local dev_id - dev_id=$(lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) + dev_id=$(timeout 2 lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) [ -z "$dev_id" ] && { echo false; return; } local dev_int @@ -23,7 +23,7 @@ is_nvidia_kepler() { is_nvidia_fermi() { local dev_id - dev_id=$(lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) + dev_id=$(timeout 2 lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) [ -z "$dev_id" ] && { echo false; return; } local dev_int @@ -56,7 +56,7 @@ is_nvidia_fermi() { is_nvidia_maxwell() { local dev_id - dev_id=$(lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) + dev_id=$(timeout 2 lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) [ -z "$dev_id" ] && { echo false; return; } local dev_int @@ -76,7 +76,7 @@ is_nvidia_maxwell() { is_nvidia_pascal() { local dev_id - dev_id=$(lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) + dev_id=$(timeout 2 lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) [ -z "$dev_id" ] && { echo false; return; } local dev_int @@ -98,7 +98,7 @@ is_nvidia_pascal() { is_nvidia_blackwell() { local dev_id - dev_id=$(lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) + dev_id=$(timeout 2 lspci -nn | grep -iE "VGA|3D" | grep -i nvidia | grep -oP '10de:\K[0-9a-fA-F]+' | head -n1) [ -z "$dev_id" ] && { echo false; return; } local dev_int @@ -114,7 +114,7 @@ is_nvidia_blackwell() { is_amd_legacy_gcn() { local dev_id - dev_id=$(lspci -nn | grep -iE "VGA|3D" | grep -i amd | grep -oP '1002:\K[0-9a-fA-F]{4}' | head -n1) + dev_id=$(timeout 2 lspci -nn | grep -iE "VGA|3D" | grep -i amd | grep -oP '1002:\K[0-9a-fA-F]{4}' | head -n1) [ -z "$dev_id" ] && { echo false; return; } local legacy_ids diff --git a/modules/sysinfo.sh b/modules/sysinfo.sh index dee9e7c..021b9ae 100644 --- a/modules/sysinfo.sh +++ b/modules/sysinfo.sh @@ -27,7 +27,7 @@ _show_sysinfo() { if echo "$gpu_line" | grep -qi "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) [ -z "$nv_ver" ] && nv_ver=$(dpkg -l nvidia-driver 2>/dev/null | awk '/^ii/ {print $3}' | sed 's/-.*//') msg+="GPU ${gpu_count}: ${desc}\n" msg+=" Driver: ${nv_ver:+NVIDIA }${nv_ver:-not installed}\n" @@ -37,7 +37,7 @@ _show_sysinfo() { msg+="GPU ${gpu_count}: ${desc}\n" msg+=" Driver: ${mesa_ver:+Mesa }${mesa_ver:-unknown}\n" fi - done < <(lspci -nn | grep -E "VGA|3D" || true) + done < <(timeout 2 lspci -nn | grep -E "VGA|3D" || true) fi if ! $found_gpu; then @@ -52,13 +52,13 @@ _show_sysinfo() { declare -a pci_eth_lines=() while IFS= read -r line; do pci_eth_lines+=("$line") - done < <(lspci -d ::0200 2>/dev/null || true) + done < <(timeout 2 lspci -d ::0200 2>/dev/null || true) # ── 2. Detect ALL WiFi chipsets (class 0x0280 + vendor fallbacks) ── declare -a pci_wifi_lines=() while IFS= read -r line; do pci_wifi_lines+=("$line") - done < <(lspci -d ::0280 2>/dev/null || true) + done < <(timeout 2 lspci -d ::0280 2>/dev/null || true) # Broadcom vendor-ID fallback (14e4) — include only if not already captured while IFS= read -r line; do @@ -69,7 +69,7 @@ _show_sysinfo() { done ! $already && pci_wifi_lines+=("$line") fi - done < <(lspci -nn 2>/dev/null || true) + done < <(timeout 2 lspci -nn 2>/dev/null || true) # USB WiFi fallback local usb_wifi_lines=() diff --git a/modules/utils.sh b/modules/utils.sh index 45d7151..3af1bee 100644 --- a/modules/utils.sh +++ b/modules/utils.sh @@ -191,7 +191,7 @@ detect_kernel() { # ---------------------------------- detect_gpu() { local gpu_lines - gpu_lines=$(lspci -nn | grep -E "VGA|3D") || true + gpu_lines=$(timeout 2 lspci -nn | grep -E "VGA|3D") || true if [ -z "$gpu_lines" ]; then GPU_TYPE="unknown" GPU_DESC="No GPU detected" @@ -201,7 +201,8 @@ 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 || true; do + while IFS= read -r line || [[ -n "$line" ]]; do + [[ -z "$line" ]] && continue local desc desc=$(echo "$line" | sed -E 's/.*: //; s/ *\(rev.*//') [ -n "$desc_lines" ] && desc_lines+=" + " @@ -282,21 +283,21 @@ declare -a WIFI_SSIDS=() detect_network() { local eth_line - eth_line=$(lspci -nn | grep -i 'Ethernet controller' | head -n1) || true + eth_line=$(timeout 2 lspci -nn | grep -i 'Ethernet controller' | head -n1) || true if [ -n "$eth_line" ]; then ETH_DESC=$(echo "$eth_line" | sed -E 's/^.*\]: //; s/ \[[0-9a-fA-F]{4}:[0-9a-fA-F]{4}\]//; s/ \(rev [0-9a-fA-F]+\)//') fi local wifi_line # Layer 1: grep by PCI class description text - wifi_line=$(lspci -nn 2>/dev/null | grep -iE 'network controller|wireless|wi-fi|wlan|802\.11' | head -n1) || true + wifi_line=$(timeout 2 lspci -nn 2>/dev/null | grep -iE 'network controller|wireless|wi-fi|wlan|802\.11' | head -n1) || true # Layer 2: grep by exact PCI class code 0x0280 (Network controller) if [ -z "$wifi_line" ]; then - wifi_line=$(lspci -d ::0280 2>/dev/null | head -n1) || true + wifi_line=$(timeout 2 lspci -d ::0280 2>/dev/null | head -n1) || true fi # Layer 3: Broadcom vendor ID fallback (14e4) if [ -z "$wifi_line" ]; then - wifi_line=$(lspci -nn 2>/dev/null | grep -i '14e4:' | head -n1) || true + wifi_line=$(timeout 2 lspci -nn 2>/dev/null | grep -i '14e4:' | head -n1) || true fi if [ -n "$wifi_line" ]; then WIFI_CHIPSET="$wifi_line" @@ -382,7 +383,7 @@ detect_storage() { elif [ "$rota" = "1" ]; then type="HDD" else - rm=$(cat /sys/block/"$name"/removable 2>/dev/null || echo 0) + rm=$(timeout 2 cat /sys/block/"$name"/removable 2>/dev/null || echo 0) if [ "$rm" = "1" ]; then type="USB/SD" else