#!/bin/bash VERSION="570.133.07" FILENAME="NVIDIA-Linux-x86_64-${VERSION}.run" URL="https://us.download.nvidia.com/XFree86/Linux-x86_64/${VERSION}/${FILENAME}" NVIDIA_FOLDER_LOCATION="/opt/nvidia" DRIVER_LOCATION="${NVIDIA_FOLDER_LOCATION}/downloads/${FILENAME}" PATCH_LOCATION="${NVIDIA_FOLDER_LOCATION}/nvidia-patch/patch.sh" NVIDIA_SMI="$(command -v nvidia-smi)" if [ ${NVIDIA_SMI} ]; then INSTALLED_VERSION="$(nvidia-smi | awk '/Driver Version/ {print $6}')" else INSTALLED_VERSION="000.000.000" fi # get installed version if installed and compare to version listed above if [ "${VERSION}" != "${INSTALLED_VERSION}" ]; then # Check and install the nvidia driver if [ ! -f "${DRIVER_LOCATION}" ]; then # download as file is misisng wget -P $(dirname ${DRIVER_LOCATION}) ${URL} fi # ensure the driver can run chmod +x ${DRIVER_LOCATION} # install the driver silently ${DRIVER_LOCATION} -s fi # After install Patch the driver cd $(dirname ${PATCH_LOCATION}) # pull latest git git pull --quiet # ensure patch can run chmod +x ${PATCH_LOCATION} # run the patch ${PATCH_LOCATION}