chore: check for file existence when removing

This commit is contained in:
Eli Bosley
2025-07-08 15:29:27 -04:00
parent 318d9e35d6
commit 7ff5db5573

View File

@@ -145,12 +145,27 @@ exit 0
echo "Removing Plugin"
# Check Unraid version
UNRAID_VERSION=$(cat /etc/unraid-version | grep "^version=" | cut -d'"' -f2)
# Check if this is Unraid 7.2 or higher (including RCs and prereleases)
UNRAID_VERSION=""
is_7_2_or_higher=false
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
# 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 "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