base-files: fix status display command
authorAlexander Egorenkov <egorenar-dev@posteo.net>
Sun, 28 Mar 2021 08:45:08 +0000 (10:45 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 18 Apr 2021 10:05:54 +0000 (12:05 +0200)
If service() is called w/o parameter then the status display for services
with multiple instances is incorrect. E.g. samba4 or wpad have 2 instances.

root@OpenWrt:~# /etc/init.d/samba4 status
running
root@OpenWrt:~# /etc/init.d/wpad status
running

Before change:
/etc/init.d/samba4                 enabled         stopped
/etc/init.d/wpad                   enabled         stopped

After change:
/etc/init.d/samba4                 enabled         running
/etc/init.d/wpad                   enabled         running

Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net>
(cherry picked from commit 9318f61556c5443eb66eec7e26715b00f0df86fc)

package/base-files/files/etc/shinit

index 8c64e81563f5694707ea99aa7435a10328d5b8a2..0a1ebcc832deebd91b85368768aa38319425bc0b 100644 (file)
@@ -22,7 +22,7 @@ service() {
                        printf "%-30s\t%10s\t%10s\n"  "$F" \
                        $( $($F enabled) && echo "enabled" || echo "disabled" ) \
                        $( [ "$(ubus call service list "{ 'verbose': true, 'name': '$(basename $F)' }" \
-                       | jsonfilter -q -e "@.$(basename $F).instances[*].running")" = "true" ] \
+                       | jsonfilter -q -e "@.$(basename $F).instances[*].running" | uniq)" = "true" ] \
                        && echo "running" || echo "stopped" )
                done;
                return 1