scripts/fresh-install/detect_gpu.sh

53 lines
1.6 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Lightweight GPU detection script.
# Detects GPU vendor and invokes the corresponding vendor install/management script.
# Exports: GPU_VENDOR
2025-11-01 15:36:22 +01:00
# shellcheck source=./install_nvidia_driver.sh
# shellcheck source=./install_amd_driver.sh
# shellcheck source=./install_intel_driver.sh
set -e
GPU_VENDOR="unknown"
PCI_GPU_INFO=$(lspci -nn | grep -Ei 'vga|3d|display' || true)
if echo "$PCI_GPU_INFO" | grep -qi nvidia; then
2025-11-01 15:36:22 +01:00
GPU_VENDOR="nvidia"
elif echo "$PCI_GPU_INFO" | grep -Eqi '\b(amd|advanced micro devices|ati)\b'; then
2025-11-01 15:36:22 +01:00
GPU_VENDOR="amd"
elif echo "$PCI_GPU_INFO" | grep -qi intel; then
2025-11-01 15:36:22 +01:00
GPU_VENDOR="intel"
fi
export GPU_VENDOR
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
case "$GPU_VENDOR" in
nvidia)
if [ -x "$SCRIPT_DIR/install_nvidia_driver.sh" ]; then
2025-11-01 15:36:22 +01:00
# shellcheck source=./install_nvidia_driver.sh disable=SC1091
. "$SCRIPT_DIR/install_nvidia_driver.sh"
else
echo "NVIDIA installer script missing: $SCRIPT_DIR/install_nvidia_driver.sh"
fi
;;
amd)
if [ -x "$SCRIPT_DIR/install_amd_driver.sh" ]; then
2025-11-01 15:36:22 +01:00
# shellcheck source=./install_amd_driver.sh disable=SC1091
. "$SCRIPT_DIR/install_amd_driver.sh"
else
echo "AMD installer script missing: $SCRIPT_DIR/install_amd_driver.sh (placeholder)"
fi
;;
intel)
if [ -x "$SCRIPT_DIR/install_intel_driver.sh" ]; then
2025-11-01 15:36:22 +01:00
# shellcheck source=./install_intel_driver.sh disable=SC1091
. "$SCRIPT_DIR/install_intel_driver.sh"
else
echo "Intel installer script missing: $SCRIPT_DIR/install_intel_driver.sh"
fi
;;
*)
echo "Unknown / no discrete GPU detected."
;;
esac