Skip to content

Commit 4636a36

Browse files
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.
1 parent 36f3e56 commit 4636a36

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

MerlinAU.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ _Unmount_WebUI_()
17981798
}
17991799

18001800
##----------------------------------------##
1801-
## Modified by Martinski W. [2025-Jan-05] ##
1801+
## Modified by Martinski W. [2025-Jan-12] ##
18021802
##----------------------------------------##
18031803
_AutoStartupHook_()
18041804
{
@@ -1825,24 +1825,28 @@ _AutoStartupHook_()
18251825
fi
18261826
else
18271827
{
1828-
echo "#!/bin/sh" ; echo
1829-
echo '[ -x '"$theScriptFilePath"' ] && '"$theScriptFilePath"' startup "$@" & '"$theScriptNameTag"
1830-
echo
1828+
echo "#!/bin/sh" ; echo
1829+
echo '[ -x '"$theScriptFilePath"' ] && '"$theScriptFilePath"' startup "$@" & '"$theScriptNameTag"
1830+
echo
18311831
} > "$theHookScriptFile"
18321832
fi
18331833
chmod 755 "$theHookScriptFile"
18341834
;;
18351835
delete)
1836-
if [ -f "$theHookScriptFile" ] && grep -q "$theScriptNameTag" "$theHookScriptFile"
1836+
if [ -f "$theHookScriptFile" ] && \
1837+
{ grep -q "$theScriptNameTag" "$theHookScriptFile" || \
1838+
grep -q "$theScriptFilePath" "$theHookScriptFile" ; }
18371839
then
1840+
theFixedPath="$(echo "$theScriptFilePath" | sed 's/[\/.]/\\&/g')"
18381841
sed -i "/${theScriptNameTag}/d" "$theHookScriptFile"
1842+
sed -i "/$theFixedPath startup/d" "$theHookScriptFile"
18391843
fi
18401844
;;
18411845
esac
18421846
}
18431847

18441848
##----------------------------------------##
1845-
## Modified by Martinski W. [2025-Jan-05] ##
1849+
## Modified by Martinski W. [2025-Jan-12] ##
18461850
##----------------------------------------##
18471851
_AutoServiceEvent_()
18481852
{
@@ -1871,14 +1875,19 @@ _AutoServiceEvent_()
18711875
{
18721876
echo "#!/bin/sh" ; echo
18731877
echo 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME"'" ; then { '"$theScriptFilePath"' service_event "$@" & }; fi '"$theScriptNameTag"
1874-
} >> "$theHookScriptFile"
1878+
echo
1879+
} > "$theHookScriptFile"
18751880
fi
18761881
chmod 755 "$theHookScriptFile"
18771882
;;
18781883
delete)
1879-
if [ -f "$theHookScriptFile" ] && grep -q "$theScriptNameTag" "$theHookScriptFile"
1884+
if [ -f "$theHookScriptFile" ] && \
1885+
{ grep -q "$theScriptNameTag" "$theHookScriptFile" || \
1886+
grep -q "$theScriptFilePath" "$theHookScriptFile" ; }
18801887
then
1888+
theFixedPath="$(echo "$theScriptFilePath" | sed 's/[\/.]/\\&/g')"
18811889
sed -i "/${theScriptNameTag}/d" "$theHookScriptFile"
1890+
sed -i "/$theFixedPath service_event/d" "$theHookScriptFile"
18821891
fi
18831892
;;
18841893
esac

0 commit comments

Comments
 (0)