necessary changes & cleanup

- removed wait for network
- necessary changes for 6.11+
-cleanup
This commit is contained in:
2022-07-22 16:02:39 +02:00
parent 18b3f765a7
commit c27b803b99

View File

@@ -2,17 +2,22 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "nct6687-driver">
<!ENTITY author "ich777">
<!ENTITY version "2021.07.30">
<!ENTITY version "2022.07.22">
<!ENTITY gitURL "https://github.com/&author;/unraid-&name;/raw/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="6.9.0">
<CHANGES>
###2022.07.21
- Version detection from package via GitHub API
- Save md5 in packages directory
###2021.07.30
- Removed max version 6.10.0-beta25a
@@ -53,33 +58,14 @@ Source: https://github.com/Fred78290/nct6687d
<FILE Run="/bin/bash">
<INLINE>
KERNEL_V="$(uname -r)"
PACKAGE="nct6687d-plugin-$KERNEL_V"
DL_URL="https://github.com/ich777/unraid-nct6687-driver/releases/download/$KERNEL_V"
#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%%-*}")
if [ ! -f "&plugin;/&name;.png" ]; then
wget -q -nc -O "&plugin;/&name;.png" "https://raw.githubusercontent.com/ich777/docker-templates/master/ich777/images/nuvoton.png"
fi
download() {
#Download NCT6687d Drivers
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
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
@@ -87,22 +73,17 @@ if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&plugin;/packag
else
echo
echo "-----------------------Can't download NCT6687d Drivers-----------------------"
rm -rf &plugin; &emhttp;
exit 1
fi
}
check() {
if [ ! -f "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" ]; then
if ! ls -1 &packages;/${KERNEL_V%%-*}/ | grep -q "${PACKAGE}" ; then
echo
echo "-----------------------Downloading NCT6687d Drivers!-------------------------"
echo "---------This could take some time, please don't close this window!----------"
download
elif [ ! -s "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz" ]; then
rm -rf &plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz
echo
echo "----Download is empty please contact the developer of this plugin if the-----"
echo "----------plugin has been already built against that Kernel version----------"
exit 1
else
echo
echo "-----------------------NCT6687d Drivers found locally------------------------"
@@ -113,12 +94,37 @@ install() {
#Install NCT6687d Drivers
/sbin/installpkg "&plugin;/packages/${KERNEL_V%%-*}/${PACKAGE}-1.txz"
depmod -a
}
activate() {
/sbin/modprobe nct6687
}
# Define Variables
KERNEL_V="$(uname -r)"
PACKAGE="nct6687d"
DL_URL="https://github.com/ich777/unraid-nct6687-driver/releases/download/$KERNEL_V"
if [ ! -d "&plugin;/packages/${KERNEL_V%%-*}" ]; then
mkdir -p "&plugin;/packages/${KERNEL_V%%-*}"
fi
if [ ! -f "&plugin;/&name;.png" ]; then
wget -q -nc -O "&plugin;/&name;.png" "https://raw.githubusercontent.com/ich777/docker-templates/master/ich777/images/nuvoton.png"
fi
#Check for old packages
rm -rf $(ls -d &plugin;/packages/* | grep -v "${KERNEL_V%%-*}")
#Check if NCT6687d Drivers are allready downloaded
check
install > /dev/null
if ! modinfo nct6687 -0 >/dev/null 2>&amp;1 ; then
install > /dev/null
activate
else
activate
fi
#Install icon
if [ ! -f "&emhttp;/images/&name;.png" ]; then
@@ -142,8 +148,7 @@ echo "-----------------------------------"
echo "---Uninstalling NCT6687d Drivers---"
echo "-----------------------------------"
# Remove plugin related files
rm -rf /usr/local/emhttp/plugins/&name;
rm -rf &plugin;
rm -rf &plugin; &emhttp;
echo
echo "--------------------------------------------------------------"
echo "---NCT6687d Drivers uninstalled, please reboot your server!---"