Skip to content

Instantly share code, notes, and snippets.

@eladc
Forked from aont/download_nvidia_driver.sh
Last active June 12, 2016 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eladc/30c08a97663ff2c30fb12a7a8d95742d to your computer and use it in GitHub Desktop.
Save eladc/30c08a97663ff2c30fb12a7a8d95742d to your computer and use it in GitHub Desktop.
Download and install Latest NVIDIA driver on Debian based OS
#!/bin/bash
## this script is for Debian\Ubuntu.
## Check if root
if [ ! $UID = 0 ]; then
echo "This script needs super user privileges to run"
echo "run it againg using sudo or login as root"
exit 1
fi
## Stop the DM:
service lightdm stop
service gdm stop
service kdm stop
## remove existing drivers, install dkms
apt-get update
apt-get purge nvidia*
apt-get install dkms
## Get file name
LATEST_FILE="ftp://download.nvidia.com/XFree86/Linux-x86_64/latest.txt"
BASE_URL="http://uk.download.nvidia.com/XFree86/Linux-x86_64"
## Check curl || wget
if [ -f /usr/bin/curl ]; then
function dl_name() {
curl -s "$1"
}
function dl() {
curl -o "$2" "$1"
}
elif [ -f /usr/bin/wget ]; then
function dl_name() {
wget -q -O - "$1"
}
function dl() {
wget -O $2 $1
}
fi
PATH_LATEST="$(dl_name $LATEST_FILE | cut -d" " -f2)"
FILE_NAME="$(basename $PATH_LATEST)"
FILE_URL="$BASE_URL/$PATH_LATEST"
## Download
dl "$FILE_URL" "$FILE_NAME"
## Execute
chmod +x "$FILE_NAME"
sh "$FILE_NAME"
## Reboot
echo "Reboot your system.."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment