[OpenWrt-Devel] [PATCH 1/2] base-files: implement generic service_running

Petr Štetiar ynezz at true.cz
Tue Jul 23 06:24:51 EDT 2019


DRY is good, otherwise we're going to suffer with a copy&paste disease
in the init scripts.

Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 package/base-files/files/etc/rc.common | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
index 75dbeedf34d4..3bd382ae27ac 100755
--- a/package/base-files/files/etc/rc.common
+++ b/package/base-files/files/etc/rc.common
@@ -95,7 +95,11 @@ service_data() {
 }
 
 service_running() {
-	return 0
+	[ -n "$USE_PROCD" ] || return 0
+
+	local service="${1:-$(basename $initscript)}"
+	local instance="${2:-*}"
+	procd_running "$service" "${instance}" "$@"
 }
 
 ${INIT_TRACE:+set -x}
@@ -104,6 +108,9 @@ ${INIT_TRACE:+set -x}
 
 [ -n "$USE_PROCD" ] && {
 	EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace"
+	EXTRA_HELP="\
+	running	Check if service is running
+	"
 
 	. $IPKG_INSTROOT/lib/functions/procd.sh
 	basescript=$(readlink "$initscript")

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list