mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-12-25 21:09:45 +00:00
b35ad5bacc
* feat(fedora/nvidia-*.sh): adding nvidia proprietary driver setup * fix(fedora/nvidia-*.sh): removing update line That update line crashed my system while testing, since it also installed new kernal where I didn't build my driver. So new user can also get confused. * refactor(fedora/nvidia-*.sh): adding a new warning while starting the script I faced this issue yesterday, So It's better to warn user before installing this driver * refactor(fedora/nvidia-*.sh): removing uninstalation option For now, as suggested by @nnyyxxxx and @adamperkowski, I'm removing the uninstall option until #362 gets resolved. * Fix bashism --------- Co-authored-by: Chris Titus <contact@christitus.com>
95 lines
2.8 KiB
Bash
Executable File
95 lines
2.8 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
. ../../common-script.sh
|
|
# This script allows user to download proprietary drivers for nvidia in fedora
|
|
|
|
# It also disables noveau nvidia drivers
|
|
|
|
# Installation guide link: https://rpmfusion.org/Howto/NVIDIA
|
|
|
|
# NOTE: Currently script only provides drivers for gpu 2014 and above (510+ and above)
|
|
|
|
checkRepo() {
|
|
REPO_ID="rpmfusion-nonfree-nvidia-driver"
|
|
|
|
if [ $(dnf repolist enabled 2>/dev/null | grep "$REPO_ID" | wc -l) -gt 0 ]; then
|
|
printf "%b\n" "${GREEN}Nvidia non-free repository is already enabled.${RC}"
|
|
else
|
|
printf "%b\n" "${YELLOW}Nvidia non-free repository is not enabled. Enabling now...${RC}"
|
|
|
|
# Enable the repository
|
|
$ESCALATION_TOOL dnf config-manager --set-enabled "$REPO_ID"
|
|
|
|
# Refreshing repository list
|
|
$ESCALATION_TOOL dnf makecache
|
|
|
|
# Verify if the repository is enabled
|
|
if [ $(dnf repolist enabled 2>/dev/null | grep "$REPO_ID" | wc -l) -gt 0 ]; then
|
|
printf "%b\n" "${GREEN}Nvidia non-free repository is now enabled...${RC}"
|
|
else
|
|
printf "%b\n" "${RED}Failed to enable nvidia non-free repository...${RC}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
checkDriverInstallation() {
|
|
if modinfo -F version nvidia >/dev/null 2>&1; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
installDriver() {
|
|
|
|
if checkDriverInstallation; then
|
|
printf "%b\n" "${GREEN}NVIDIA driver is already installed.${RC}"
|
|
exit 0
|
|
fi
|
|
|
|
# NOTE:: Installing graphics driver.
|
|
$ESCALATION_TOOL dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y
|
|
printf "%b\n" "${YELLOW}Building the drivers may take upto 5 minutes. Please don't kill the script!\n If the build failed try running the script again, select \"Remove Nvidia Drivers\" and reboot the system, then try installing drivers again.${RC}"
|
|
|
|
for i in {1..5}; do
|
|
if checkDriverInstallation; then
|
|
printf "%b\n" "${GREEN}Driver installed successfully.${RC}"
|
|
printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}"
|
|
break
|
|
fi
|
|
printf "%b\n" "${YELLOW}Waiting for driver to be built..."
|
|
sleep 1m
|
|
done
|
|
|
|
printf "%b\n" "${GREEN}Now you can reboot the system.${RC}"
|
|
|
|
}
|
|
|
|
# NOTE: A confirmation option to proceed or not
|
|
userConfirmation() {
|
|
printf "%b" "${YELLOW}Do you want to continue? (Y/N): ${RC}"
|
|
read -r choice
|
|
case "$choice" in
|
|
y | Y)
|
|
checkRepo
|
|
installDriver
|
|
return
|
|
;;
|
|
n | N)
|
|
printf "%b\n" "${RED} Exiting the Script ${RC}"
|
|
return
|
|
;;
|
|
*)
|
|
printf "%b\n" "${RED} Invalid Option! ${RC}"
|
|
userConfirmation
|
|
;;
|
|
esac
|
|
}
|
|
|
|
printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free repository and only install drivers for GPUs from 2014 or later. It works on fedora 34 and above.\n It is recommended remove this driver while updating your kernel packages to newer version.${RC}"
|
|
|
|
checkEnv
|
|
checkEscalationTool
|
|
userConfirmation
|