diff --git a/plugin/plugins/dynamix.unraid.net.plg b/plugin/plugins/dynamix.unraid.net.plg index 4eff30bae..7429e30a6 100755 --- a/plugin/plugins/dynamix.unraid.net.plg +++ b/plugin/plugins/dynamix.unraid.net.plg @@ -144,15 +144,60 @@ exit 0 /dev/null | head -1) - if [ -n "$pkg_installed" ]; then - pkg_basename=$(basename "$pkg_installed") - echo "Removing package: $pkg_basename" - removepkg --terse "$pkg_basename" + # Check Unraid version + UNRAID_VERSION="" + is_7_2_or_higher=false + + # Check if version file exists and is readable + if [ -f "/etc/unraid-version" ] && [ -r "/etc/unraid-version" ]; then + UNRAID_VERSION=$(cat /etc/unraid-version | grep "^version=" | cut -d'"' -f2 2>/dev/null) + + if [ -z "$UNRAID_VERSION" ]; then + echo "Warning: Unable to parse version from /etc/unraid-version" + echo "Using safe removal method (plugin file removal + reboot)" + is_7_2_or_higher=true # Default to safe method + else + # Check if this is Unraid 7.2 or higher (including RCs and prereleases) + if [[ "$UNRAID_VERSION" =~ ^7\.([2-9]|[1-9][0-9]+)\. ]] || [[ "$UNRAID_VERSION" =~ ^([8-9]|[1-9][0-9]+)\. ]]; then + is_7_2_or_higher=true + fi + fi else - echo "No dynamix.unraid.net package found. Trying with basic package name." - removepkg --terse "${MAINNAME}" + echo "Warning: /etc/unraid-version file not found or not readable" + echo "Using safe removal method (plugin file removal + reboot)" + is_7_2_or_higher=true # Default to safe method + fi + + if [ "$is_7_2_or_higher" = true ]; then + echo "Unraid 7.2+ detected. Using safe removal method." + + # Send notification to user + /usr/local/emhttp/webGui/scripts/notify \ + -e "Unraid Connect" \ + -s "Reboot Required for Unraid Connect Removal" \ + -d "Unraid Connect plugin has been marked for removal. Please reboot your server to complete the uninstallation." \ + -i "warning" + + # Remove the plugin file so it won't be installed on reboot + PLUGIN_FILE="/boot/config/plugins/${MAINNAME}.plg" + if [ -f "$PLUGIN_FILE" ]; then + echo "Removing plugin file: $PLUGIN_FILE" + rm -f "$PLUGIN_FILE" + fi + + echo "Plugin marked for removal. Reboot required to complete uninstallation." + else + # Original removal method for older versions + # Find any installed dynamix.unraid.net package + pkg_installed=$(ls -1 /var/log/packages/dynamix.unraid.net* 2>/dev/null | head -1) + if [ -n "$pkg_installed" ]; then + pkg_basename=$(basename "$pkg_installed") + echo "Removing package: $pkg_basename" + removepkg --terse "$pkg_basename" + else + echo "No dynamix.unraid.net package found. Trying with basic package name." + removepkg --terse "${MAINNAME}" + fi fi # File restoration function