unraid-amd-vendor-reset/amd-vendor-reset.plg

197 lines
6.9 KiB
Plaintext
Raw Normal View History

2021-05-25 15:11:32 +00:00
<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "AMD-Vendor-Reset">
<!ENTITY author "ich777">
2022-04-11 15:35:38 +00:00
<!ENTITY version "2022.04.11">
2021-05-25 15:14:32 +00:00
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unraid-amd-vendor-reset/master">
2021-05-25 15:11:32 +00:00
<!ENTITY pluginURL "&gitURL;/amd-vendor-reset.plg">
<!ENTITY plugin "/boot/config/plugins/amd-vendor-reset">
2021-05-25 15:33:34 +00:00
<!ENTITY emhttp "/usr/local/emhttp/plugins/AMD-Vendor-Reset">
2021-05-25 15:11:32 +00:00
]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" min="6.10.0-beta17">
<CHANGES>
2022-04-11 15:29:02 +00:00
###2022.04.11
- Added Plugin Update Helper when up-/downgrading unRAID version
2022-03-21 08:08:46 +00:00
###2022.03.21
- Added change for reset_method for Kernel 5.15+
2021-06-23 09:47:27 +00:00
###2021.06.23
- Changed package download repo
2021-05-25 15:11:32 +00:00
###2021.05.25
- Initial release
</CHANGES>
<FILE Name="&emhttp;/README.md">
<INLINE>
2021-06-23 09:47:27 +00:00
**AMD Vendor Reset**
2021-05-25 15:11:32 +00:00
2021-06-23 09:47:27 +00:00
This package contains the Vendor Reset module for Polaris, Vega10/20 and Navi10/12/14 cards by Adam Madsen and Geoffrey McRae. You can get more details here: https://github.com/gnif/vendor-reset
2021-05-25 15:11:32 +00:00
</INLINE>
</FILE>
<FILE Run="/bin/bash">
<INLINE>
KERNEL_V="$(uname -r)"
2021-06-23 09:47:27 +00:00
PACKAGE="gnif_vendor_reset-plugin-${KERNEL_V}"
DL_URL="https://github.com/ich777/unraid-amd-vendor-reset/releases/download/$KERNEL_V"
2021-05-25 15:11:32 +00:00
#Wait for Network and timeout after 30 seconds
HOST="8.8.8.8"
for i in {1..10}; do
ping -c1 $HOST &amp;> /dev/null &amp;&amp; break;
done
if [ ! -d "&plugin;/packages/${KERNEL_V%%-*}" ]; then
mkdir -p "&plugin;/packages/${KERNEL_V%%-*}"
fi
#Check for old packages
rm -rf $(ls -d &plugin;/packages/* | grep -v "${KERNEL_V%%-*}")
2021-05-25 15:33:34 +00:00
if [ ! -f "&plugin;/AMD-Vendor-Reset.png" ]; then
2021-06-23 09:47:27 +00:00
wget -q -nc --show-progress --progress=bar:force:noscroll -O "&plugin;/&name;.png" "https://raw.githubusercontent.com/ich777/docker-templates/master/ich777/images/gnif.png"
2021-05-25 15:33:34 +00:00
fi
2021-05-25 15:11:32 +00:00
download() {
#Download vendor-reset
if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" "${DL_URL}/${PACKAGE}-1.txz" ; then
if [ "$(md5sum "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" | cut -d ' ' -f1)" != "$(wget -qO- "${DL_URL}/${PACKAGE}-1.txz.md5" | cut -d ' ' -f1)" ]; then
echo
echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------"
echo "--------------------------------CHECKSUM ERROR!---------------------------------"
exit 1
fi
echo
2021-06-23 09:47:27 +00:00
echo "----------Successfully downloaded AMD Vendor Reset, please wait...!-----------"
2021-05-25 15:11:32 +00:00
else
echo
echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR-----"
2021-06-23 09:47:27 +00:00
echo "----------------------Can't download AMD Vendor Reset--------------------------"
2021-05-25 15:11:32 +00:00
exit 1
fi
}
check() {
if [ ! -f "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" ]; then
echo
2021-06-23 09:47:27 +00:00
echo "-----------------Downloading AMD Vendor Reset, please wait...!----------------"
2021-05-25 15:11:32 +00:00
echo "----------This could take some time, please don't close this window!----------"
download
else
echo
2021-06-23 09:47:27 +00:00
echo "-----------------------AMD Vendor Reset found locally!------------------------"
2021-05-25 15:11:32 +00:00
fi
}
install() {
2021-06-23 09:47:27 +00:00
#Install AMD Vendor Reset
2021-05-25 15:11:32 +00:00
/sbin/installpkg "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz"
depmod -a
modprobe vendor_reset
}
2021-06-23 09:47:27 +00:00
#Check if AMD Vendor Reset is already downloaded
2021-05-25 15:11:32 +00:00
check
2022-04-11 15:29:02 +00:00
#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 &lt;(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 &lt;(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 &gt; /dev/null 2&gt;&amp;1
fi
2021-05-25 15:11:32 +00:00
if [ ! -z "$(lsmod | grep "vendor_reset")" ]; then
modprobe vendor_reset
echo
2021-06-23 09:47:27 +00:00
echo "------------Nothing to do, AMD Vendor Reset is already installed!-------------"
2021-05-25 15:11:32 +00:00
echo
else
echo
2021-06-23 09:47:27 +00:00
echo "-----------------Installing AMD Vendor Reset, please wait...!-----------------"
2021-05-25 15:11:32 +00:00
install > /dev/null
echo
2021-06-23 09:47:27 +00:00
echo "----------------Installation of AMD Vendor Reset successful-------------------"
2021-05-25 15:11:32 +00:00
echo
fi
2022-03-21 08:08:46 +00:00
#Change reset_method for installed AMD VGA adapters for Kernel 5.15+
#https://github.com/gnif/vendor-reset/issues/46#issuecomment-992282166
TARGET_V="5.14.99"
COMPARE="$(uname -r | cut -d '-' -f1)
$TARGET_V"
if [ "$TARGET_V" != "$(echo "$COMPARE" | sort -V | tail -1)" ]; then
while read -r line
do
echo 'device_specific' &gt; $(find /sys/bus/pci/devices/* -name "*$line")/reset_method
done &lt;&lt;&lt; "$(lspci -nn | grep -E "VGA compatible controller|Display controller" | grep -E "AMD|ATI|Advanced Micro Devices" | awk '{print $1}')"
fi
2021-05-25 15:33:34 +00:00
#Install icon
2021-06-23 09:47:27 +00:00
if [ ! -f "&emhttp;/images/&name;.png" ]; then
2021-05-25 15:37:30 +00:00
if [ ! -d "&emhttp;/images" ]; then
2021-05-25 15:33:34 +00:00
mkdir -p &emhttp;/images
fi
2021-06-23 09:47:27 +00:00
cp &plugin;/&name;.png &emhttp;/images/
2021-05-25 15:33:34 +00:00
fi
2021-05-25 15:11:32 +00:00
</INLINE>
</FILE>
<FILE Run="/bin/bash" Method="remove">
<INLINE>
echo "----------------------------------------"
2021-06-23 09:47:27 +00:00
echo "-----Uninstalling AMD Vendor Reset------"
2021-05-25 15:11:32 +00:00
echo "----------------------------------------"
# Remove plugin related files
rm -rf &emhttp;
rm -rf &plugin;
echo
echo "----------------------------------------------------------------------------"
2021-06-23 09:47:27 +00:00
echo "---------AMD Vendor Reset uninstalled, please reboot your server!-----------"
2021-05-25 15:11:32 +00:00
echo "----------------------------------------------------------------------------"
echo
</INLINE>
</FILE>
</PLUGIN>