fix: do not uninstall fully on 7.2 (#1484)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Uninstallation process now adapts based on Unraid version: for version
7.2 or higher, users receive a notification and are prompted to reboot
to complete plugin removal.
* **Bug Fixes**
* Improved handling of plugin removal to ensure compatibility with
different Unraid versions and prevent unintended reinstalls.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Eli Bosley
2025-07-08 15:44:30 -04:00
committed by GitHub
parent 5edfd823b8
commit 22638811a9

View File

@@ -144,15 +144,60 @@ exit 0
<![CDATA[
echo "Removing Plugin"
# 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"
# 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