[openwrt/openwrt] base-files: add wrapper for procd service list command

LEDE Commits lede-commits at lists.infradead.org
Sat Mar 19 09:30:46 PDT 2022


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/09c41ea6792a86cfcacb13f6727f5049c3f87cd6

commit 09c41ea6792a86cfcacb13f6727f5049c3f87cd6
Author: Florian Eckert <fe at dev.tdt.de>
AuthorDate: Wed Dec 22 08:59:43 2021 +0100

    base-files: add wrapper for procd service list command
    
    A service managed by procd does have a json object with usefull information.
    This information could by dumped with the following command.
    
    ubus call service list "{ 'verbose':true, 'name': '<service-name>)'". }"
    
    This line is long and complicated to enter. This commit adds a wrapper
    call to the procd service section tool to simplify the input and get the
    output faster.
    
    We could now enter the command /etc/initd/<service> info to get the info
    faster.
    
    Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
 package/base-files/files/etc/rc.common | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
index e950ec209d..d747303844 100755
--- a/package/base-files/files/etc/rc.common
+++ b/package/base-files/files/etc/rc.common
@@ -126,6 +126,7 @@ extra_command "enabled" "Check if service is started on boot"
 	extra_command "running" "Check if service is running"
 	extra_command "status" "Service status"
 	extra_command "trace" "Start with syscall trace"
+	extra_command "info" "Dump procd service info"
 
 	. $IPKG_INSTROOT/lib/functions/procd.sh
 	basescript=$(readlink "$initscript")
@@ -149,6 +150,13 @@ extra_command "enabled" "Check if service is started on boot"
 		start "$@"
 	}
 
+	info() {
+		json_init
+		json_add_string name "$(basename ${basescript:-$initscript})"
+		json_add_boolean verbose "1"
+		_procd_ubus_call list
+	}
+
 	stop() {
 		procd_lock
 		stop_service "$@"




More information about the lede-commits mailing list