mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-09-14 06:02:35 +00:00
f0be860f98
- Refined `_show_nvidia_version_menu` in `modules/gpu/nvidia.sh` for Debian 12/13 with precise labels ("Newest Stable", "Kepler Support") and explicit official repo recommendations.
- Introduced new standalone module `modules/gpu/nvidia_manage.sh` integrated into the dispatcher to handle driver lifecycle management (Install/Change vs Remove) before version selection.
- Implemented safe removal logic (`_nvidia_remove`) with explicit package purging, explicitly excluding `firmware-misc-nonfree`, and cleaning specific configs/repos without wildcards.
- Ensured idempotency across all steps using `|| true` and preserved user CUDA toolkits while restoring Nouveau via initramfs regeneration.
57 lines
2.0 KiB
Bash
57 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
# nvidia_manage.sh — NVIDIA management menu: install/change or remove
|
|
|
|
_nvidia_manage_menu() {
|
|
local choice
|
|
choice=$(_menu "NVIDIA Driver" "Manage NVIDIA Driver" 12 70 4 \
|
|
"1" "Install / Change NVIDIA Driver Version" \
|
|
"2" "Remove NVIDIA Driver and Restore Nouveau")
|
|
|
|
[ -z "$choice" ] && {
|
|
echo "Skipping NVIDIA installation."
|
|
return 1
|
|
}
|
|
|
|
case "$choice" in
|
|
2)
|
|
_nvidia_remove
|
|
return 1
|
|
;;
|
|
*) return 0 ;;
|
|
esac
|
|
}
|
|
|
|
_nvidia_remove() {
|
|
if ! dpkg -l 2>/dev/null | grep -qE "^ii (nvidia-driver|nvidia-tesla-470-driver|nvidia-open-kernel-dkms|nvidia-kernel-dkms)"; then
|
|
echo -e "${YELLOW}NVIDIA driver is not installed on this system.${NC}"
|
|
return 0
|
|
fi
|
|
|
|
if ! _confirm "Remove NVIDIA" "This will:\n - Purge the NVIDIA driver packages\n - Remove script-generated configs\n - Remove the CUDA repo sources\n - Regenerate initramfs\n\nProceed?"; then
|
|
echo "NVIDIA removal cancelled."
|
|
return 0
|
|
fi
|
|
|
|
echo "Removing NVIDIA driver packages..."
|
|
sudo apt purge -y nvidia-driver nvidia-kernel-dkms nvidia-open-kernel-dkms nvidia-tesla-470-driver nvidia-settings nvidia-vaapi-driver firmware-nvidia-gsp mesa-vdpau-drivers || true
|
|
|
|
echo "Cleaning up dependencies..."
|
|
sudo apt autoremove --purge -y || true
|
|
|
|
echo "Removing script-generated configuration..."
|
|
sudo rm -f /etc/modprobe.d/nvidia-wayland.conf || true
|
|
sudo rm -f /etc/modprobe.d/nvidia-open.conf || true
|
|
sudo rm -f /etc/apt/preferences.d/block-nvidia || true
|
|
sudo rm -f /etc/X11/xorg.conf.d/20-nvidia.conf || true
|
|
|
|
echo "Removing NVIDIA repository sources..."
|
|
sudo rm -f /etc/apt/sources.list.d/cuda-*.list || true
|
|
sudo rm -f /etc/apt/sources.list.d/extrepo_nvidia-cuda.sources || true
|
|
|
|
echo "Regenerating initramfs..."
|
|
sudo update-initramfs -u || true
|
|
|
|
echo -e "${GREEN}NVIDIA driver removed. Please reboot your system.${NC}"
|
|
return 0
|
|
}
|