Files
unraid-memryx-driver/memryx-driver.plg

195 lines
6.8 KiB
XML

<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "memryx-driver">
<!ENTITY author "ich777">
<!ENTITY version "2025.05.05">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unraid-&name;/master">
<!ENTITY pluginURL "&gitURL;/&name;.plg">
<!ENTITY plugin "/boot/config/plugins/&name;">
<!ENTITY emhttp "/usr/local/emhttp/plugins/&name;">
<!ENTITY packages "/boot/config/plugins/&name;/packages">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" min="7.1.0-rc.1" support="https://forums.unraid.net/topic/92865-support-ich777-amd-vendor-reset-coraltpu-hpsahba/">
<CHANGES>
###2025.05.05
- Initial release
</CHANGES>
<FILE Name="&emhttp;/README.md">
<INLINE>
**MemryX Driver**
This package contains the MemryX MX3 Module Drivers and installs them to utilize them in your Docker containers.
</INLINE>
</FILE>
<FILE Run="/bin/bash">
<INLINE>
download() {
# Download MemryX Module Drivers
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 "---CHECKSUM ERROR!---"
rm -rf &plugin; &emhttp;
exit 1
fi
echo
echo "----------Successfully downloaded MemryX Module Drivers-----------"
else
echo
echo "--------------Can't download MemryX Module Drivers----------------"
rm -rf &plugin; &emhttp;
exit 1
fi
}
check() {
if ! ls -1 &packages;/${KERNEL_V%%-*}/ | grep -q "${PACKAGE}" ; then
LAT_PACKAGE="$(wget -qO- https://api.github.com/repos/ich777/unraid-memryx-driver/releases/tags/${KERNEL_V} | jq -r '.assets[].name' | grep "${PACKAGE}" | grep -E -v '\.md5$' | sort -V | tail -1)"
echo
echo "---------------Downloading MemryX Module Drivers!-----------------"
echo "----This could take some time, please don't close this window!----"
download
else
echo
echo "---------------MemryX Module Drivers found locally----------------"
fi
}
install() {
# Install MemryX Module Drivers
/sbin/installpkg "&packages;/${KERNEL_V%%-*}/${PACKAGE}*.txz"
depmod -a
}
activate() {
# Modprobe modules
/sbin/modprobe memx_cascade_plus_pcie
}
# Define Variables
KERNEL_V="$(uname -r)"
PACKAGE="memryx"
DL_URL="https://github.com/ich777/unraid-memryx-driver/releases/download/$KERNEL_V"
if [ ! -d "&packages;/${KERNEL_V%%-*}" ]; then
mkdir -p "&packages;/${KERNEL_V%%-*}"
fi
#Check for old packages
rm -rf $(ls -d &packages;/* | grep -v "${KERNEL_V%%-*}")
#Check if MemryX Module Drivers are already downloaded
check
#Check if drivers are available or need to be installed
if ! modinfo memx_cascade_plus_pcie -0 >/dev/null 2>&amp;1 ; then
install > /dev/null
fi
#Check if drivers are already loaded
if ! lsmod | grep "memx_cascade_plus_pcie" >/dev/null 2>&amp;1 ; then
activate
fi
#Copy over settings files if not found
if [ ! -f "&plugin;/mxa_manager.conf" ]; then
cp /etc/memryx/mxa_manager.sample &plugin;/mxa_manager.conf
fi
if [ ! -f "&plugin;/power.conf" ]; then
cp /etc/memryx/power.sample &plugin;/power.conf
fi
#Check if symlinks for configs are in place
if [ ! -L /etc/memryx/mxa_manager.conf ]; then
ln -s &plugin;/mxa_manager.conf /etc/memryx/mxa_manager.conf
fi
if [ ! -L /etc/memryx/power.conf ]; then
ln -s &plugin;/power.conf /etc/memryx/power.conf
fi
#Get base port from config
BASE_PORT="$(cat /etc/memryx/mxa_manager.conf | grep "BASE_PORT" | cut -d '=' -f2)"
#Check if daemon is already running and start mxa_manager daemon in background if not running
if [ -z "$(pgrep --ns $$ mxa_manager)" ]; then
echo "------------Starting mxa_manager daemon on Port: ${BASE_PORT}------------"
echo "/usr/bin/mxa_manager &gt;/dev/null 2&gt;&amp;1" | at now -M &gt;/dev/null 2&gt;&amp;1
else
echo "--------mxa_manager daemon already running on Port: ${BASE_PORT}---------"
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 &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
echo
echo "---------Installation of MemryX Module Drivers successful---------"
echo
</INLINE>
</FILE>
<FILE Run="/bin/bash" Method="remove">
<INLINE>
echo "---------------------------------------------"
echo "-----Uninstalling MemryX Module Drivers------"
echo "---------------------------------------------"
# Stop mxa_manager
kill -SIGTERM $(pgrep --ns $$ mxa_manager)
# Remove plugin related files
rm -rf &emhttp;
rm -rf &plugin;
echo
echo "----------------------------------------------------------------------------"
echo "-------MemryX Module Drivers uninstalled, please reboot your server!--------"
echo "----------------------------------------------------------------------------"
echo
</INLINE>
</FILE>
</PLUGIN>