Skip to content

Instantly share code, notes, and snippets.

@vondraussen
Created January 19, 2021 15:54
Show Gist options
  • Save vondraussen/9806b04cec4326d496170afd9ed052a3 to your computer and use it in GitHub Desktop.
Save vondraussen/9806b04cec4326d496170afd9ed052a3 to your computer and use it in GitHub Desktop.
bash script to check installed and available (online) nvidia driver. it can download the latest as well. I use it if I end up with a black screen after Kernel update.
#!/bin/bash
# Installed Version
# modinfo nvidia | grep 'version:'
INSTALLED=`modinfo nvidia | grep '^version' | sed -r 's/version:.*([0-9]{3}\.[0-9]{2})/\1/'`
# Latest Long Lived Branch Version
AVAILABLE=`curl -s https://www.nvidia.com/en-us/drivers/unix/ | tr -d [:blank:] | \
grep -A 2 'Linuxx86_64/AMD64/EM64T' | \
grep 'LatestProductionBranchVersion' | \
grep -Po -m1 '(?<=>)[\d]{3}.[\d]{2,3}.[\d]{2,3}(?=<)' | head -1`
echo "installed: ${INSTALLED}"
echo "available: ${AVAILABLE}"
while test $# -gt 0
do
case "$1" in
--download) echo "downloading latest driver ${AVAILABLE}";
wget "https://us.download.nvidia.com/XFree86/Linux-x86_64/${AVAILABLE}/NVIDIA-Linux-x86_64-${AVAILABLE}.run" -O ~/Downloads/NVIDIA-Linux-x86_64-${AVAILABLE}.run
chmod +x ~/Downloads/NVIDIA-Linux-x86_64-${AVAILABLE}.run
;;
--*) echo "bad option $1"
;;
*) echo "argument $1"
;;
esac
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment