]> ###2022.09.01 - fix package ###2022.08.22-1 - fix package ###2022.08.22 - fix package ###2022.08.15 - fix package ###2022.08.14 - Initial release rm -f $(ls /boot/config/plugins/&name;/&name;*.txz 2>/dev/null|grep -v '&version;') &gitURL;/packages/&name;-&version;.txz &md5; **Nvidia Vgpu Driver** This plugin will install the nvidia vgpu driver, which will reuse your graphics card in a virtual machine download() { #Download Nvidia Vgpu Driver Package if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}" "${DL_URL}/${LAT_PACKAGE}" ; then wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5" "${DL_URL}/${LAT_PACKAGE}.md5" if [ "$(md5sum &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE} | awk '{print $1}')" != "$(cat &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5 | awk '{print $1}')" ]; then echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "--------------------------------CHECKSUM ERROR!---------------------------------" rm -rf &plugin; &emhttp; exit 1 fi echo sed -i '/driver_version=/c\driver_version=latest' "&plugin;/settings.cfg" echo "----Successfully downloaded Nvidia Vgpu Driver Package v$(echo $LAT_PACKAGE | cut -d '-' -f3), please wait!----" else echo echo "--------------Can't download Nvidia Driver Package v$(echo $LAT_PACKAGE | cut -d '-' -f3)-----------------" rm -rf &plugin; &emhttp; exit 1 fi } get_version() { LAT_PACKAGE="$(wget -qO- https://api.github.com/repos/DanITman/unraid-nvidia-vgpu-driver/releases/tags/${KERNEL_V} | jq -r '.assets[].name' | grep "${PACKAGE}" | grep -E -v '\.md5$' | sort -V | tail -1)" if [ -z "$LAT_PACKAGE" ]; then if [ -z "$CUR_V" ]; then echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "---Can't get latest Nvidia vgpu driver version and found no installed local driver---" rm -rf &plugin; &emhttp; exit 1 else LAT_PACKAGE=${CUR_V} fi fi } #Check if driver is already downloaded check() { if ! ls -1 &packages;/${KERNEL_V%%-*}/ | grep -q "${PACKAGE}" ; then get_version 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 Vgpu Driver Package v$(echo $LAT_PACKAGE | cut -d '-' -f3)------------------" echo "----------This could take some time, please don't close this window!------------" download else LAT_PACKAGE=$CUR_V echo echo "--------------------Nvidia vgpu driver v$(echo $LAT_PACKAGE | cut -d '-' -f3) found locally---------------------" fi } #Install driver package install() { /sbin/installpkg "&packages;/${KERNEL_V%%-*}/${PACKAGE}*.txz" ## depmod >> /dev/null ## modprobe nvidia >> /dev/null } activate() { if [ "$(which Xorg 2>/dev/null)" ] && [ "$(cat /boot/config/plugins/nvidia-vgpu-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 [[ "$SET_DRV_V" != "latest" && "$SET_DRV_V" != "latest_prb" && "$SET_DRV_V" != "latest_nfb" ]]; then sed -i '/update_check=/c\update_check=false' "&plugin;/settings.cfg" fi } #Set variables KERNEL_V="$(uname -r)" PACKAGE="nvidia" DL_URL="https://github.com/DanITman/unraid-nvidia-vgpu-driver/releases/download/${KERNEL_V}" if [ ! -d "&packages;/${KERNEL_V%%-*}" ]; then mkdir -p "&packages;/${KERNEL_V%%-*}" CUR_V="" else CUR_V="$(ls -p &packages;/${KERNEL_V%%-*} 2>/dev/null | grep -E -v '\.md5' | sort -V | tail -1)" fi #Create settings file if not found if [ ! -f "&plugin;/settings.cfg" ]; then echo 'first_installation=true driver_version=latest disable_xconfig=false update_check=true' > "&plugin;/settings.cfg" fi #Add update check entry if not exists if [ ! "$(grep -q "update_check=" &plugin;/settings.cfg)" ]; then echo "update_check=true" >> &plugin;/settings.cfg fi if [ "$(grep -q "local_version=" &plugin;/settings.cfg)" ]; then sed -i '/local_version=/d' &plugin;/settings.cfg fi #Move old package directory to new package directory to be compliant with 6.11 if find &packages; -maxdepth 1 -type f -name "*.txz" 2>/dev/null ; then mv $(find &packages; -maxdepth 1 -type f -name "*.txz") &packages;/${KERNEL_V%%-*}/ 2>/dev/null CUR_V="$(ls -p &packages;/${KERNEL_V%%-*} 2>/dev/null | grep -E -v '\.md5' | sort -V | tail -1)" fi #Check if Nvidia vgpu Driver Package is already downloaded check #Check for old packages that are not suitable for this Kernel and not suitable for the current Nvidia vgpu driver version rm -f $(ls -d &packages;/* 2>/dev/null | grep -v "${KERNEL_V%%-*}") rm -f $(ls &packages;/${KERNEL_V%%-*}/* 2>/dev/null | grep -v "$LAT_PACKAGE") #Install Nvidia vgpu Driver Package if ! modinfo nvidia -0 >/dev/null 2>&1 ; then echo echo "-----------------Installing Nvidia Vgpu Driver Package v$(echo $LAT_PACKAGE | cut -d '-' -f3)-------------------" install > /dev/null activate else activate fi #Enable update check if [ "$UPDATE_CHECK" == "true" ]; then if [ ! "$(crontab -l | grep "/usr/local/emhttp/plugins/nvidia-vgpu-driver/include/update-check.sh")" ]; then (crontab -l ; echo ""$((0 + $RANDOM % 59))" "$(shuf -i 8-9 -n 1)" * * * /usr/local/emhttp/plugins/nvidia-vgpu-driver/include/update-check.sh &>/dev/null 2>&1") | crontab - fi fi #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 Vgpu Driver" -d "Please go to -> Settings -> nvidia-vgpu-driver Perform Set up" sed -i '/first_installation=true/c\first_installation=false' "&plugin;/settings.cfg" echo echo "------------Installation of Nvidia vgpu driver v$(echo $LAT_PACKAGE | cut -d '-' -f3) successful----------------" echo echo "Nvidia Vgpu Driver" -d "Please go to -> Settings -> nvidia-vgpu-driver Perform Set up" else sed -i '/first_installation=true/c\first_installation=false' "&plugin;/settings.cfg" echo echo "--------------Installation of Nvidia vgpu driver v$(echo $LAT_PACKAGE | cut -d '-' -f3) successful--------------" 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/DanITman/unraid-nvidia-vgpu-driver/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/DanITman/unraid-nvidia-vgpu-driver/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/DanITman/unraid-nvidia-vgpu-driver/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 echo "----------------------------------------" echo "---Uninstalling Nvidia vGPU driver package---" echo "----------------------------------------" # Remove plugin related files removepkg &name;-&version; crontab -l | grep -v '/usr/local/emhttp/plugins/nvidia-vgpu-driver/include/update-check.sh &>/dev/null 2>&1' | crontab - rm -rf /usr/local/emhttp/plugins/&name; rm -rf &plugin; echo echo "--------------------------------------------------------------------------------" echo "-------------Nvidia vGPU Driver uninstalled, please reboot your server!--------------" echo "--------------------------------------------------------------------------------" echo