]> ###2022.05.06 - When notifications via Mail is setup don't send message about download progress anymore ###2022.04.29 - Changed default driver download from Latest Production Branch back to Latest ###2022.04.11 - Removed warning messages from console on boot ###2022.01.20 - Changed default driver download from Latest to Latest Production Branch ###2021.09.17 - Fixed plugin to escape variables properly ###2021.09.15 - Added message to New Feature and Production Branch if no driver package is found for current unRAID version ###2021.07.30 - Bugfix, thanks to cybrnook ###2021.07.29 - Added Plugin Update Helper when up-/downgrading unRAID version ###2021.06.23 - Fixed error message on boot after upgrade to newer unRAID version - Corrected a few typos ###2021.06.23 - Changed package download repo ###2021.05.19 - Added driver update notification ###2021.04.29 - Added options to select latest version from 'Production Branch' and 'New Feature Branch' ###2021.04.16 - Fixed bug where local_version wasn't updated in settings file when driver was downloaded through WebUI - Fixed plugin showing no version numbers when drivers where not found on Github - Show only last 8 Drivers on plugin page ###2021.03.22 - Use IP address instead of hostname for online check - Fixed Plugin Error with fallback URL if no internet connection is available on boot ###2021.03.19 - Fixed restart message shown if the version is changed from the latest to the latest driver version number and vice versa - reported by binhex - Driver numbers file is updated now once every 5 minutes if the Plugin page is accessed several times within a short period of time ###2021.03.17 - Added detection if unRAID is booted into GUI-Mode ###2021.03.16 - Added option to disable creation of xorg.conf file - requested by TechGeek01 ###2021.03.12 - Fixed Permissions - Added wait for network including timeout ###2021.03.10 - Fixed error when booting into GUI mode that the screen only shows blinking cursor ###2021.03.09 - Fixed Radio Buttons not showing current selected driver version - reported by binhex - Added Fallback URL until update handling is sorted ###2021.03.07 - Added Download button to WebGUI to download the Nvidia Driver instantly if no internet connection is available at boot - Corrected a few typos - Display Warning message only when downloading the Nvidia Driver ###2021.03.04 - Changed download repo to Github ###2020.12.13 - Fixed bug where the plugin folder isn't removed on a failed download ###2020.11.15 - Added addtional warning to not close the window until the DONE button is displayed at the first installation - Added link to support thread ###2020.10.27 - Added check if enough space is available on USB boot device - Description of Plugin page and link changed - Added driver version selection - Added check for old packages ###2020.10.24 - Json parsing - MD5 hash check - Fallback to latest Nvidia version if version for current Kernel isn't found - Fallback to local Nvidia version if no Internet connection is available or parsing of release.json failed ###2020.10.23 - Initial release rm -f $(ls /boot/config/plugins/&name;/&name;*.txz 2>/dev/null|grep -v '&version;') &gitURL;/packages/&name;-&version;.txz &md5; **Nvidia Driver** This plugin will install the Nvidia drivers to utilize your Nvidia graphics card in your Docker container(s). This plugin satisfies installation prerequisites of the GPU Statistics plugin from Community Apps. With both plugins installed you can display Nvidia GPU utilization on the unRAID Dashboard. #Create settings file if not found if [ ! -f "&plugin;/settings.cfg" ]; then echo 'first_installation=true driver_version=latest local_version=none disable_xconfig=false update_check=true' > "&plugin;/settings.cfg" fi #Add update check entry if not exists if [ ! "$(grep "update_check=" &plugin;/settings.cfg)" ]; then echo "update_check=true" >> &plugin;/settings.cfg fi #Wait for Network and timeout after 30 seconds HOST="8.8.8.8" for i in {1..10}; do ping -c1 $HOST &> /dev/null && break; done #Set variables KERNEL_V="$(uname -r)" DRIVER_AVAIL="$(wget -qO- https://api.github.com/repos/ich777/unraid-nvidia-driver/releases/tags/${KERNEL_V} | jq -r '.assets[].name' | grep -E 'nvidia-.*.txz' | grep -E -v '\.md5$' | awk -F "-" '{print $2}' | sort -V)" NV_DRV_V="$(grep "driver_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" #Fallback until how updates are handled is sorted if [ -z "$DRIVER_AVAIL" ]; then echo echo "-------Main download URL not reachable, using Fallback URL-------" DRIVER_AVAIL="$(wget -qO- https://s3.amazonaws.com/dnld.lime-technology.com/drivers/releases.json | jq -r '.[] | "\(.kernel) \(.version) \(.url) \(.md5) \(.size)" | select( index("'${KERNEL_V}'"))')" if [ ! -z "$DRIVER_AVAIL" ]; then DL_DRV="$(echo $DRIVER_AVAIL | awk '{print $2}' | head -1)" DL_URL="$(echo $DRIVER_AVAIL | awk '{print $3}' | head -1)" MD5_SUM="$(echo $DRIVER_AVAIL | awk '{print $4}' | head -1)" DRIVER_AVAIL="$(echo $DRIVER_AVAIL | awk '{print $1}' | head -1)" if [ "$(ping -c1 s3.amazonaws.com &> /dev/null; echo $? )" == "0" ]; then FALLBACK="true" else echo echo "----------------Fallback URL also not reachable!-----------------" echo "---Are you sure that you have a active internet connection and---" echo "--------no container like PiHole running on your server?---------" fi fi fi #Check Nvidia driver version and set download variable, if Nvidia driver version #is not found for this kernel fall back to latest, if no Internet connection or parsing of #release.json failed fall back to local installed version if no local version is found exit. if [ "${NV_DRV_V}" == "latest" ]; then if [ -z "$DRIVER_AVAIL" ]; then if [ "$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" == "none" ]; then if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "---Can't get latest Nvidia driver version and found no installed local driver---" exit 1 else NV_DRV_V="$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi else DL_DRV="$(echo "$DRIVER_AVAIL" | tail -1)" NV_DRV_V="${DL_DRV}" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi elif [ "${NV_DRV_V}" == "latest_prb" ]; then LAT_PRB_AVAIL="$(wget -qO- https://raw.githubusercontent.com/ich777/versions/master/nvidia_versions | grep 'PRB' | cut -d '=' -f2 | sort -V)" if [ -z "$DRIVER_AVAIL" ]; then if [ "$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" == "none" ]; then if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "---Can't get latest Nvidia driver version and found no installed local driver---" exit 1 else NV_DRV_V="$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi elif [ -z "$(comm -12 <(echo "$DRIVER_AVAIL") <(echo "$LAT_PRB_AVAIL") 2> /dev/null | sort -V | tail -1)" ]; then echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "----Can't get Production Branch version and found no installed local driver-----" echo "-----Please wait for an hour and try it again, if it then also fails please-----" echo "------go to the Support Thread on the unRAID forums and make a post there!------" exit 1 else DL_DRV="$(comm -12 <(echo "$DRIVER_AVAIL") <(echo "$LAT_PRB_AVAIL") 2> /dev/null | sort -V | tail -1)" NV_DRV_V="${DL_DRV}" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi elif [ "${NV_DRV_V}" == "latest_nfb" ]; then LAT_NFB_AVAIL="$(wget -qO- https://raw.githubusercontent.com/ich777/versions/master/nvidia_versions | grep 'NFB' | cut -d '=' -f2 | sort -V)" if [ -z "$DRIVER_AVAIL" ]; then if [ "$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" == "none" ]; then if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "---Can't get latest Nvidia driver version and found no installed local driver---" exit 1 else NV_DRV_V="$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi elif [ -z "$(comm -12 <(echo "$DRIVER_AVAIL") <(echo "$LAT_NFB_AVAIL") 2> /dev/null | sort -V | tail -1)" ]; then echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "----Can't get New Feature Branch version and found no installed local driver----" echo "-----Please wait for an hour and try it again, if it then also fails please-----" echo "------go to the Support Thread on the unRAID forums and make a post there!------" exit 1 else DL_DRV="$(comm -12 <(echo "$DRIVER_AVAIL") <(echo "$LAT_NFB_AVAIL") 2> /dev/null | sort -V | tail -1)" NV_DRV_V="${DL_DRV}" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi else if [ -z "$DRIVER_AVAIL" ]; then if [ "$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" == "none" ]; then if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "---Can't get latest Nvidia driver version and found no installed local driver---" exit 1 else NV_DRV_V="$(grep "local_version" "&plugin;/settings.cfg" | cut -d '=' -f2)" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi else DL_DRV="$(echo "$DRIVER_AVAIL" | grep "$NV_DRV_V")" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") if [ -z "${DL_DRV}" ]; then NV_DRV_OLD=${NV_DRV_V} DL_DRV="$(echo "$DRIVER_AVAIL" | tail -1)" NV_DRV_V="$(echo "$DL_DRV")" echo echo "---Can't find Nvidia Driver v${NV_DRV_OLD} for your Kernel v${KERNEL_V%%-*} falling back to latest Nvidia Driver v${NV_DRV_V}---" sed -i '/driver_version=/c\driver_version=latest' "&plugin;/settings.cfg" #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia driver version rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$KERNEL_V") rm -f $(ls &plugin;/packages/nvidia-*-1.txz 2>/dev/null | grep -v "$NV_DRV_V") fi fi fi if [ ! -d "&plugin;/packages" ]; then mkdir -p "&plugin;/packages" fi #Download Nvidia Driver Package download() { if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&plugin;/packages/nvidia-${NV_DRV_V}-${KERNEL_V}-1.txz" "https://github.com/ich777/unraid-nvidia-driver/releases/download/${KERNEL_V}/nvidia-${DL_DRV}-${KERNEL_V}-1.txz" ; then if [ "$(md5sum "&plugin;/packages/nvidia-${NV_DRV_V}-${KERNEL_V}-1.txz" | cut -d ' ' -f1)" != "$(wget -qO- "https://github.com/ich777/unraid-nvidia-driver/releases/download/${KERNEL_V}/nvidia-${DL_DRV}-${KERNEL_V}-1.txz.md5" | cut -d ' ' -f1)" ]; then if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "--------------------------------CHECKSUM ERROR!---------------------------------" exit 1 fi sed -i '/local_version=/c\local_version='${NV_DRV_V}'' "&plugin;/settings.cfg" echo echo "----Successfully downloaded Nvidia Driver Package v${NV_DRV_V}, please wait!----" else if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "--------------Can't download Nvidia Driver Package v${NV_DRV_V}-----------------" exit 1 fi } #Download Nvidia Driver Package Fallback download_fb() { if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&plugin;/packages/nvidia-${NV_DRV_V}-${KERNEL_V}-1.txz" "$(echo "$DL_URL")" ; then if [ "$(md5sum "&plugin;/packages/nvidia-${NV_DRV_V}-${KERNEL_V}-1.txz" | cut -d ' ' -f1)" != "${MD5_SUM}" ]; then if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "--------------------------------CHECKSUM ERROR!---------------------------------" exit 1 fi sed -i '/local_version=/c\local_version='${NV_DRV_V}'' "&plugin;/settings.cfg" echo echo "-----------Sucessfully downloaded Nvidia Driver Package v${NV_DRV_V}-------------" else if [ -d &plugin; ]; then rm -rf &plugin; fi echo echo "---------------Can't download Nvidia Driver Package v${NV_DRV_V}-----------------" exit 1 fi } #Check if driver is already downloaded check() { if [ ! -f &plugin;/packages/nvidia-${NV_DRV_V}-${KERNEL_V}-1.txz ]; then echo echo "+==============================================================================" echo "| WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING" echo "|" echo "| Don't close this window with the red 'X' in the top right corner until the 'DONE' button is displayed!" echo "|" echo "| WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING" echo "+==============================================================================" echo echo "-----------------Downloading Nvidia Driver Package v${NV_DRV_V}------------------" echo "----------This could take some time, please don't close this window!------------" if [ "${FALLBACK}" == "true" ]; then download_fb else download fi else echo echo "--------------------Nvidia driver v${NV_DRV_V} found locally---------------------" fi } #Install driver package install() { /sbin/installpkg "&plugin;/packages/nvidia-${NV_DRV_V}-${KERNEL_V}-1.txz" depmod >> /dev/null modprobe nvidia >> /dev/null if [ "$(which Xorg 2>/dev/null)" ] && [ "$(cat /boot/config/plugins/nvidia-driver/settings.cfg | grep "disable_xconfig" | cut -d '=' -f2)" != "true" ]; then nvidia-xconfig --output-xconfig=/etc/X11/xorg.conf --silent 2>/dev/null fi if [ "$(cat &plugin;/settings.cfg | grep "local_version=" | cut -d '=' -f2)" != "${NV_DRV_V}" ]; then sed -i '/local_version=/c\local_version='${NV_DRV_V}'' "&plugin;/settings.cfg" fi if [[ "$(cat &plugin;/settings.cfg | grep "driver_version=" | cut -d '=' -f2)" != "latest" && "$(cat &plugin;/settings.cfg | grep "driver_version=" | cut -d '=' -f2)" != "latest_prb" && "$(cat &plugin;/settings.cfg | grep "driver_version=" | cut -d '=' -f2)" != "latest_nfb" ]]; then sed -i '/update_check=/c\update_check=false' "&plugin;/settings.cfg" fi if [ "$(cat &plugin;/settings.cfg | grep "update_check=" | cut -d '=' -f2)" == "true" ]; then (crontab -l ; echo ""$((0 + $RANDOM % 59))" "$(shuf -i 8-9 -n 1)" * * * /usr/local/emhttp/plugins/nvidia-driver/include/update-check.sh &>/dev/null 2>&1") | crontab - fi } #Check if Nvidia Driver Package is already downloaded if [ -f /usr/bin/nvidia-smi ]; then echo echo "-----------------------Nvidia Drivers already installed!-------------------------" if [ "$(cat &plugin;/settings.cfg | grep "update_check=" | cut -d '=' -f2)" == "true" ]; then if [ ! "$(crontab -l | grep "/usr/local/emhttp/plugins/nvidia-driver/include/update-check.sh")" ]; then (crontab -l ; echo ""$((0 + $RANDOM % 59))" "$(shuf -i 8-9 -n 1)" * * * /usr/local/emhttp/plugins/nvidia-driver/include/update-check.sh &>/dev/null 2>&1") | crontab - fi fi exit 0 else check fi #Check if Plugin Update Helper is downloaded and up-to-date if [ ! -f &plugin;/plugin_update_helper ]; then wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper" else CUR_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')" if [ ! -s /tmp/update-helper ]; then echo "$(wget -T5 -qO- https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper | grep -E "Plugin-Update-Helper version:" | awk '{print $4}')" > /tmp/update-helper AVAIL_V="$(cat /tmp/update-helper)" else AVAIL_V="$(cat /tmp/update-helper)" fi if [ ! -z "$AVAIL_V" ]; then COMPARE="$(sort -V <(echo -e "${AVAIL_V}\n$CUR_V") | tail -1)" if [ "$CUR_V" != "$COMPARE" ]; then wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper" fi fi fi #Check if Plugin Update Helper is installed and up to date if [ ! -f /usr/bin/plugin_update_helper ]; then cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper chmod +x /usr/bin/plugin_update_helper else PLUGIN_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')" INST_V="$(grep -E "Plugin-Update-Helper version:" /usr/bin/plugin_update_helper | awk '{print $4}')" COMPARE="$(sort -V <(echo -e "${PLUGIN_V}\n$INST_V") | tail -1)" if [ "$INST_V" != "$COMPARE" ]; then kill $(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}') 2>/dev/null sleep 1 cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper chmod +x /usr/bin/plugin_update_helper fi fi #Start Plugin Update Helper if [ -z "$(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}')" ]; then echo "/usr/bin/plugin_update_helper" | at now -M > /dev/null 2>&1 fi #Install Nvidia Driver Package echo echo "-----------------Installing Nvidia Driver Package v${NV_DRV_V}-------------------" install > /dev/null #Display message to disable and enable Docker on first installation or display successful message if [ "$(grep "first_installation=" "&plugin;/settings.cfg" | cut -d '=' -f2)" == "true" ]; then /usr/local/emhttp/plugins/dynamix/scripts/notify -e "Nvidia Driver" -d "Please make sure to disable and enable Docker if you installed the Nvidia driver for the first time! Settings -> Docker -> Enable Docker 'No' -> Apply -> Enable Docker 'Yes' -> Apply" -i "alert" -l "/Settings/DockerSettings" sed -i '/first_installation=true/c\first_installation=false' "&plugin;/settings.cfg" echo echo "------------Installation of Nvidia driver v${NV_DRV_V} successful----------------" echo echo "Please make sure to disable and enable Docker if you installed the Nvidia driver for the first time! Settings -> Docker -> Enable Docker 'No' -> Apply -> Enable Docker 'Yes' -> Apply" else echo echo "--------------Installation of Nvidia driver v${NV_DRV_V} successful--------------" fi echo "----------------------------------------" echo "---Uninstalling Nvidia driver package---" echo "----------------------------------------" # Remove plugin related files removepkg &name;-&version; crontab -l | grep -v '/usr/local/emhttp/plugins/nvidia-driver/include/update-check.sh &>/dev/null 2>&1' | crontab - rm -rf /usr/local/emhttp/plugins/&name; rm -rf &plugin; echo echo "--------------------------------------------------------------------------------" echo "-------------Nvidia Driver uninstalled, please reboot your server!--------------" echo "--------------------------------------------------------------------------------" echo