1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-06-17 12:43:56 +02:00

base-files: fix status display command

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 9318f61556)
This commit is contained in:
Alexander Egorenkov 2021-03-28 10:45:08 +02:00 committed by Hauke Mehrtens
parent ab610f5af3
commit eaf19220b6

View 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