From ddf6ec29b477f0cf7ce7839c8c9710fb4b969621 Mon Sep 17 00:00:00 2001 From: Alin Nastac Date: Thu, 17 Oct 2019 14:06:40 +0200 Subject: procd: allow usage of * as procd_running() instance parameter service_running() implementation in /etc/rc.common use it. It is preferable to use wildcard than assuming the instance name is the default one. jsonfilter returns all matches when wildcards are used, hence the -l 1 argument used to limit output to only one value. Signed-off-by: Alin Nastac --- package/system/procd/files/procd.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'package/system/procd/files') diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index 014b4499e1..b8f9a210f6 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -407,12 +407,12 @@ _procd_add_instance() { procd_running() { local service="$1" - local instance="${2:-instance1}" - local running + local instance="${2:-*}" + [ "$instance" = "*" ] || instance="'$instance'" json_init json_add_string name "$service" - running=$(_procd_ubus_call list | jsonfilter -e "@['$service'].instances['$instance'].running") + local running=$(_procd_ubus_call list | jsonfilter -l 1 -e "@['$service'].instances[$instance].running") [ "$running" = "true" ] } -- cgit v1.2.3