[openwrt/openwrt] base-files: fix enabled for services with only STOP

LEDE Commits lede-commits at lists.infradead.org
Tue Jun 22 12:47:02 PDT 2021


aparcar pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/cc7316d1e924977881f03a7cb5863b695f79d81e

commit cc7316d1e924977881f03a7cb5863b695f79d81e
Author: Karel Kočí <karel.koci at nic.cz>
AuthorDate: Mon Jun 7 19:25:06 2021 +0200

    base-files: fix enabled for services with only STOP
    
    There are services that have only STOP value set. They are executed only
    on shutdown and it is common to use them for system cleanup. There is
    one such service shipped directly with base-files, it is 'umount'. Those
    work the same way as those with START but enabled does not report them
    as enabled although it should have as they can be enabled and disabled
    as any other service.
    
    This also changes check from check for executable to check for symbolic
    link. The implementation depends on those being links to service file
    and it is much cleaner and direct to check for them being links.
    
    Signed-off-by: Karel Kočí <karel.koci at nic.cz>
---
 package/base-files/files/etc/rc.common | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
index f39b69464e..5dcbf5138d 100755
--- a/package/base-files/files/etc/rc.common
+++ b/package/base-files/files/etc/rc.common
@@ -55,7 +55,12 @@ enable() {
 
 enabled() {
 	name="$(basename "${initscript}")"
-	[ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
+	name="${name##[SK][0-9][0-9]}"
+	{
+		[ -z "${START:-}" ] || [ -L "$IPKG_INSTROOT/etc/rc.d/S${START}$name" ]
+	} && {
+		[ -z "${STOP:-}" ] || [ -L "$IPKG_INSTROOT/etc/rc.d/K${STOP}$name" ]
+	}
 }
 
 depends() {



More information about the lede-commits mailing list