diff options
author | Florian Eckert <fe@dev.tdt.de> | 2021-11-30 16:01:14 +0100 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2022-03-19 16:13:58 +0100 |
commit | b9017384cae7bbc47186fdf35a80207844876a0d (patch) | |
tree | f845299df9f1931cf4d6acf19236e346176a582a /package/system/procd | |
parent | b04d38a2eaa5604aa7216e0c02846d96dc2d317f (diff) | |
download | upstream-b9017384cae7bbc47186fdf35a80207844876a0d.tar.gz upstream-b9017384cae7bbc47186fdf35a80207844876a0d.tar.bz2 upstream-b9017384cae7bbc47186fdf35a80207844876a0d.zip |
procd: move service command to procd
The service command belongs to the procd and does not belong in the
shinit. In the course of the move, the script was also checked with
shellcheck and cleaned up.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'package/system/procd')
-rw-r--r-- | package/system/procd/Makefile | 1 | ||||
-rw-r--r-- | package/system/procd/files/service | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index 958a4808cb..1d27920539 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -121,6 +121,7 @@ define Package/procd/install $(INSTALL_BIN) ./files/reload_config $(1)/sbin/ $(INSTALL_CONF) ./files/hotplug*.json $(1)/etc/ $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/ + $(INSTALL_BIN) ./files/service $(1)/sbin/service endef Package/procd-selinux/install = $(Package/procd/install) diff --git a/package/system/procd/files/service b/package/system/procd/files/service new file mode 100644 index 0000000000..1ceacfe5ad --- /dev/null +++ b/package/system/procd/files/service @@ -0,0 +1,30 @@ +#!/bin/sh + +main() { + local service="$1" + local cmd="$2" + + local boot status + + if [ -f "/etc/init.d/${service}" ]; then + /etc/init.d/"${service}" "${cmd}" + exit "$?" + fi + + if [ -n "$service" ]; then + echo "Service \"$1\" not found:" + exit 1 + fi + + echo "Usage: $(basename "$0") <service> [command]" + for service in /etc/init.d/* ; do + boot="$($service enabled && echo "enabled" || echo "disabled" )" + status="$( [ "$(ubus call service list "{ 'verbose': true, 'name': '$(basename "$service")' }" \ + | jsonfilter -q -e "@['$(basename "$service")'].instances[*].running" | uniq)" = "true" ] \ + && echo "running" || echo "stopped" )" + + printf "%-30s\\t%10s\\t%10s\\n" "$service" "$boot" "$status" + done +} + +main "$@" |