Files
debianito-post-install/modules/gpu.sh
T
stornic56 3a652c28e6 system overhaul and bug fixeds
- Replaced the fragile upstream script installer with native Deb822 repository injection and automated GPG keyring management in `jellyfin.sh`. Eliminated external dependencies, checksums, and interactive flags for guaranteed non-interactive support across Bullseye/Bookworm/Trixie.
- Upgraded the NVMe module (`modules/extras/system/system.sh`) to perform multi-drive scanning with dynamic `lsblk` parsing. Replaced single-disk detection logic with a `while read` loop to capture all devices, displaying formatted SMART health diagnostics (Critical Warning, Temperature, Percentage Used).
- Overhauled the 'System Information' TUI into a multi-device dashboard featuring standalone GPU/Driver hierarchies and dynamic storage mapping. Added new globals (`DISPLAY_SERVER`, `STORAGE_SUMMARY`) and comprehensive arrays for Network/Wi-Fi interface indexing in `modules/utils.sh`.
- Redesigned the graphics stack layout to fix multi-GPU text clipping and unified Mesa version prompting logic. Integrated post-install package telemetry to display live versions in the completion screen, separating planning visualization from installation decision points in `modules/gpu.sh`.
- Fixed non-free-firmware conceptual documentation bugs and expanded Backports descriptions with hardware-focused educational text. Added non-free repository safeguards for Trixie/Bullseye compatibility under "Firmware & Wireless Drivers".
- Refactored repository logic in modules/repos.sh to eliminate dead code (redundant default_text variables) and strict-hardcoded layout behaviors, standardizing dialog geometry to a clean matrix.
- Updated README.md
2026-06-16 19:59:15 -05:00

170 lines
6.1 KiB
Bash

#!/usr/bin/env bash
# Graphics Stack — sources submodules and provides install_gpu_drivers()
_GPU_DIR="${MODULES_DIR}/gpu"
source "${_GPU_DIR}/_helpers.sh"
source "${_GPU_DIR}/amd_intel.sh"
source "${_GPU_DIR}/nvidia.sh"
# Consumed by gaming.sh to know which NVIDIA driver path was taken
NVIDIA_DRIVER_MODE=""
install_gpu_drivers() {
local info="This section installs the latest Mesa graphics stack\n"
info+="from Debian backports (or stable), plus GPU firmware\n"
info+="and monitoring tools tailored to your hardware.\n\n"
info+="Components:\n"
info+=" Mesa (OpenGL / Vulkan / VA-API)\n"
if [ "$GPU_TYPE" != "unknown" ]; then
info+=" GPU firmware\n"
fi
info+=" Monitoring tools (nvtop, vainfo, ...)"
_msg "Graphics Stack" "$info" 16 70
if ! _confirm "Graphics Stack" "Proceed with the graphics stack setup?"; then
echo "Skipping Graphics Stack."
return
fi
# ── Unknown GPU / VM block ──
if [ "$GPU_TYPE" = "unknown" ] || [ -z "$GPU_TYPE" ]; then
local mesa_pkgs=(mesa-vulkan-drivers libgl1-mesa-dri libglx-mesa0 libegl-mesa0 mesa-va-drivers)
local ref_ver
ref_ver=$(apt-cache policy mesa-vulkan-drivers 2>/dev/null | awk 'NR==3 {print $2; exit}')
local ref_bpo_ver
ref_bpo_ver=$(apt-cache madison mesa-vulkan-drivers 2>/dev/null | \
grep "${DEBIAN_CODENAME}-backports" | awk '{print $3}' | head -1)
local comp_line="Components: Vulkan, OpenGL, GLX, EGL, VA-API (64-bit)"
if [ -n "$ref_bpo_ver" ] && [ "$(is_backports_enabled)" == "true" ]; then
local header="No dedicated GPU was detected (VM or headless).\n"
header+="Install Mesa stack for compute / display acceleration?\n\n"
header+="Source: Debian ${DEBIAN_CODENAME^}-Backports\n"
header+="Mesa ${ref_bpo_ver}\n"
header+="${comp_line}\n\n"
header+="Choose version:"
if _confirm_custom "No GPU Detected" "$header" "Backports" "Stable" 14 70; then
_run_cmd "Mesa" "sudo apt install -y -t ${DEBIAN_CODENAME}-backports ${mesa_pkgs[*]}" \
"Installing Mesa from backports..."
else
_run_cmd "Mesa" "sudo apt install -y ${mesa_pkgs[*]}" \
"Installing Mesa from stable..."
fi
else
if _confirm "No GPU Detected" \
"No dedicated GPU was detected (VM or headless).\n\nInstall Mesa stack?\n\nSource: Debian Stable\nMesa ${ref_ver}\n${comp_line}" 14 70; then
_run_cmd "Mesa" "sudo apt install -y ${mesa_pkgs[*]}" \
"Installing Mesa..."
else
echo "Skipping Mesa installation."
offer_generic_tools
return
fi
fi
offer_generic_tools
echo -e "${GREEN}Graphics stack setup complete.${NC}"
return
fi
# ── Detectable GPU: build plan ──
local plan=""
local gpu_count=0
while IFS= read -r gpu_line; do
gpu_count=$((gpu_count + 1))
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)
plan+="\nComponents:\n"
if $HAS_INTEL; then
local _gen; _gen=$(get_intel_generation)
local _va; [ "$_gen" = "gen7-" ] && _va="i965-va-driver-shaders" || _va="intel-media-va-driver-non-free"
plan+=" [+] Intel firmware + ${_va}\n"
fi
if $HAS_AMD; then
plan+=" [+] AMD firmware (firmware-amd-graphics)\n"
fi
if $HAS_NVIDIA; then
plan+=" [+] NVIDIA driver\n"
fi
plan+=" [+] Mesa (version selected in next step)\n"
_msg "Graphics Stack — Plan" "$plan" 16 70
if ! _confirm "Graphics Stack" "Install the components shown above?"; then
echo "Skipping Graphics Stack."
return
fi
# ── Sequential firmware / driver installs ──
if $HAS_INTEL; then
install_intel_firmware
fi
if $HAS_AMD; then
install_amd_firmware
fi
if $HAS_NVIDIA; then
if [ "$DEBIAN_VERSION" = "11" ]; then
if type install_nvidia_bullseye &>/dev/null; then
install_nvidia_bullseye
else
install_nvidia_driver
fi
elif [ "$DEBIAN_VERSION" = "12" ]; then
if [ "$(is_nvidia_kepler)" = "true" ]; then
if type _install_nvidia_bookworm_kepler &>/dev/null; then
_install_nvidia_bookworm_kepler
else
install_nvidia_driver
fi
else
install_nvidia_driver
fi
elif [ "$DEBIAN_VERSION" = "13" ]; then
if [ "$(is_nvidia_kepler)" = "true" ]; then
_msg "NVIDIA Kepler — Trixie" \
"Your GPU is NVIDIA Kepler architecture.\nThe nvidia-tesla-470 driver is not available\nin Debian 13 (Trixie).\n\nNo NVIDIA driver will be installed for this GPU.\nOther GPUs (Intel/AMD) will still be configured."
NVIDIA_DRIVER_MODE=""
else
install_nvidia_driver
fi
else
install_nvidia_driver
fi
fi
# ── Mesa (once) ──
_install_mesa_backports
# ── Refresh GPU_VERSION after Mesa install ──
local mesa_ver
mesa_ver=$(dpkg -l libgl1-mesa-dri 2>/dev/null | awk '/^ii/ {print $3; exit}' | sed 's/-.*//')
[ -n "$mesa_ver" ] && GPU_VERSION="Mesa ${mesa_ver}"
# ── Vendor-specific tools ──
if $HAS_INTEL; then
offer_intel_tools
fi
if $HAS_AMD; then
offer_amd_tools
fi
if $HAS_NVIDIA; then
offer_generic_tools
fi
# ── Build summary ──
local summary=""
summary+="Mesa: ${GPU_VERSION:-not available}\n"
if $HAS_NVIDIA; then
local nv_mode="${NVIDIA_DRIVER_MODE:-unknown}"
summary+="NVIDIA: ${nv_mode}\n"
fi
summary+="Firmware: installed for detected GPUs\n"
summary+="Tools: installed per vendor selection"
_msg "Graphics Stack — Complete" "$summary" 12 65
}