aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2019-05-01 07:23:21 +0200
committerRafał Miłecki <rafal@milecki.pl>2019-05-02 22:14:19 +0200
commit2c3dd70741d299a236aa18acf18ac27362718abc (patch)
tree4b932bf4bcfd8c6b188590605dae6bfda9d3a197 /package
parent8696f0c3e3a9fa8c101f7653907fa1f94ff75681 (diff)
downloadupstream-2c3dd70741d299a236aa18acf18ac27362718abc.tar.gz
upstream-2c3dd70741d299a236aa18acf18ac27362718abc.tar.bz2
upstream-2c3dd70741d299a236aa18acf18ac27362718abc.zip
procd: add procd_running() helper for checking running state
This should be helpful for implementing service_running() in procd init scripts. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'package')
-rw-r--r--package/system/procd/Makefile2
-rw-r--r--package/system/procd/files/procd.sh15
2 files changed, 16 insertions, 1 deletions
diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile
index 2555105f13..03603738cd 100644
--- a/package/system/procd/Makefile
+++ b/package/system/procd/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=procd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh
index b49b2b9d01..8d6d406012 100644
--- a/package/system/procd/files/procd.sh
+++ b/package/system/procd/files/procd.sh
@@ -30,6 +30,9 @@
# procd_close_instance():
# Complete the instance being prepared
#
+# procd_running(service, [instance]):
+# Checks if service/instance is currently running
+#
# procd_kill(service, [instance]):
# Kill a service instance (or all instances)
#
@@ -402,6 +405,18 @@ _procd_add_instance() {
_procd_close_instance
}
+procd_running() {
+ local service="$1"
+ local instance="${2:-instance1}"
+ local running
+
+ json_init
+ json_add_string name "$service"
+ running=$(_procd_ubus_call list | jsonfilter -e "@.$service.instances.${instance}.running")
+
+ [ "$running" = "true" ]
+}
+
_procd_kill() {
local service="$1"
local instance="$2"