]> ###2022.07.21 - Version detection from package via GitHub API - Save md5 in packages directory ###2022.07.17 - Necessary changes for unRAID 6.11+ - Cleanup ###2022.04.12 - Removed warning message from console on boot ###2021.07.31 - Add Plugin-Update-Helper support ###01.06.2020 - initial release. download() { # Download usbip 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; exit 1 fi echo echo "-----------------Sucessfully downloaded usbip, please wait...!-----------------" else echo echo "-----ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR------" echo "----------------------------Can't download usbip--------------------------------" rm -rf &plugin; exit 1 fi } check() { # Check if packages are already downloaded or download maybe failed if ! ls -1 &packages;/${KERNEL_V%%-*}/ | grep -q "${PACKAGE}" ; then LAT_PACKAGE="$(wget -qO- https://api.github.com/repos/SimonFair/USB_Manager_USBIP_addon/releases/tags/${KERNEL_V} | jq -r '.assets[].name' | grep "${PACKAGE}" | grep -E -v '\.md5$' | sort -V | tail -1)" echo echo "---------------------Downloading usbip, please wait...!------------------------" echo "-----------This could take some time, please don't close this window!----------" download else echo echo "-----------------------------usbip found locally!------------------------------" fi } install() { # Install usbip package installpkg "&packages;/${KERNEL_V%%-*}/${PACKAGE}*.txz" depmod -a > /dev/null } check_usbip_repo() { # Check if usbip is already downloaded if not download and install it if [ ! -f "/usr/sbin/usbip" ]; then check echo "-----------------------Installing usbip, please wait...!-----------------------" install fi } # Define Variables KERNEL_V="$(uname -r)" PACKAGE="usbip" DL_URL="https://github.com/SimonFair/USB_Manager_USBIP_addon/releases/download/$KERNEL_V" # Move old package directory to new package directory to be compliant with 6.11 if [ -d &plugin;/package ]; then mv &plugin;/package &packages; fi # Check for old packages rm -rf $(ls -d &packages;/* | grep -v "${KERNEL_V%%-*}") # Create plugin directory if [ ! -d "&packages;/${KERNEL_V%%-*}" ]; then mkdir -p "&packages;/${KERNEL_V%%-*}" fi # Load Package from Releases tab for usbip modules and commands. check_usbip_repo # 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 > /dev/null 2>&1 fi echo echo "-----------------------------------------------------------" echo " &name; has been installed." echo " " echo " Copyright 2016-2022, &author;" echo " Version: &version;" echo "" echo "-----------------------------------------------------------" echo # Define Variables KERNEL_V="$(uname -r)" PACKAGE="usbip" # Remove modules from Kernel and stop usbipd modprobe -r usbip_host modprobe -r vhci_hcd killall usbipd # Remove all plugin files from emhttp. removepkg "&packages;/${KERNEL_V%%-*}/${PACKAGE}*.txz" >/dev/null 2>&1 rm -rf &plugin; depmod --quick >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo " &name; has been uninstalled." echo "-----------------------------------------------------------" echo