From 4636a367f3cf7d5b6ba64faa1bc2b79fe62dd6aa Mon Sep 17 00:00:00 2001 From: Martinski <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sun, 12 Jan 2025 03:55:55 -0800 Subject: [PATCH] Code Improvements for Uninstallation Code improvements to make sure all calls to the add-on script placed in the built-in hook scripts are removed during uninstallation. --- MerlinAU.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/MerlinAU.sh b/MerlinAU.sh index be85b7d5..d9612bd7 100644 --- a/MerlinAU.sh +++ b/MerlinAU.sh @@ -1798,7 +1798,7 @@ _Unmount_WebUI_() } ##----------------------------------------## -## Modified by Martinski W. [2025-Jan-05] ## +## Modified by Martinski W. [2025-Jan-12] ## ##----------------------------------------## _AutoStartupHook_() { @@ -1825,24 +1825,28 @@ _AutoStartupHook_() fi else { - echo "#!/bin/sh" ; echo - echo '[ -x '"$theScriptFilePath"' ] && '"$theScriptFilePath"' startup "$@" & '"$theScriptNameTag" - echo + echo "#!/bin/sh" ; echo + echo '[ -x '"$theScriptFilePath"' ] && '"$theScriptFilePath"' startup "$@" & '"$theScriptNameTag" + echo } > "$theHookScriptFile" fi chmod 755 "$theHookScriptFile" ;; delete) - if [ -f "$theHookScriptFile" ] && grep -q "$theScriptNameTag" "$theHookScriptFile" + if [ -f "$theHookScriptFile" ] && \ + { grep -q "$theScriptNameTag" "$theHookScriptFile" || \ + grep -q "$theScriptFilePath" "$theHookScriptFile" ; } then + theFixedPath="$(echo "$theScriptFilePath" | sed 's/[\/.]/\\&/g')" sed -i "/${theScriptNameTag}/d" "$theHookScriptFile" + sed -i "/$theFixedPath startup/d" "$theHookScriptFile" fi ;; esac } ##----------------------------------------## -## Modified by Martinski W. [2025-Jan-05] ## +## Modified by Martinski W. [2025-Jan-12] ## ##----------------------------------------## _AutoServiceEvent_() { @@ -1871,14 +1875,19 @@ _AutoServiceEvent_() { echo "#!/bin/sh" ; echo echo 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME"'" ; then { '"$theScriptFilePath"' service_event "$@" & }; fi '"$theScriptNameTag" - } >> "$theHookScriptFile" + echo + } > "$theHookScriptFile" fi chmod 755 "$theHookScriptFile" ;; delete) - if [ -f "$theHookScriptFile" ] && grep -q "$theScriptNameTag" "$theHookScriptFile" + if [ -f "$theHookScriptFile" ] && \ + { grep -q "$theScriptNameTag" "$theHookScriptFile" || \ + grep -q "$theScriptFilePath" "$theHookScriptFile" ; } then + theFixedPath="$(echo "$theScriptFilePath" | sed 's/[\/.]/\\&/g')" sed -i "/${theScriptNameTag}/d" "$theHookScriptFile" + sed -i "/$theFixedPath service_event/d" "$theHookScriptFile" fi ;; esac