aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorStan Grishin <stangri@melmac.net>2020-10-12 22:03:15 +0000
committerPaul Spooren <mail@aparcar.org>2020-12-03 23:28:43 -1000
commitb4f1f9c9e42fbf9008d165fc32728996b417c599 (patch)
treef6f3d3f3f7f22cad53521e513b903b772515b73f /package/base-files
parent9e7a0f45d8c4e8ccde67f80c24c7145be0130105 (diff)
downloadupstream-b4f1f9c9e42fbf9008d165fc32728996b417c599.tar.gz
upstream-b4f1f9c9e42fbf9008d165fc32728996b417c599.tar.bz2
upstream-b4f1f9c9e42fbf9008d165fc32728996b417c599.zip
base-files: informative service command in /etc/shinit. service command shows services enabled/disabled and running status, when the service command is invoked with no/invalid arguments, like this:
Usage: service <service> [command] The following services are available: /etc/init.d/acme enabled stopped /etc/init.d/boot enabled stopped /etc/init.d/cron enabled running /etc/init.d/dnsmasq enabled running ... Signed-off-by: Stan Grishin <stangri@melmac.net>
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/Makefile2
-rw-r--r--package/base-files/files/etc/shinit22
2 files changed, 18 insertions, 6 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index c06b534bea..0c612b73ca 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
include $(INCLUDE_DIR)/feeds.mk
PKG_NAME:=base-files
-PKG_RELEASE:=238
+PKG_RELEASE:=239
PKG_FLAGS:=nonshared
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
diff --git a/package/base-files/files/etc/shinit b/package/base-files/files/etc/shinit
index dccba34b69..8c64e81563 100644
--- a/package/base-files/files/etc/shinit
+++ b/package/base-files/files/etc/shinit
@@ -9,12 +9,24 @@ alias ll='ls -alF --color=auto'
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
service() {
- [ -f "/etc/init.d/$1" ] || {
- echo "service "'"'"$1"'"'" not found, the following services are available:"
- ls "/etc/init.d"
+ if [ -f "/etc/init.d/$1" ]; then
+ /etc/init.d/$@
+ else
+ echo "Usage: service <service> [command]"
+ if [ -n "$1" ]; then
+ echo "Service "'"'"$1"'"'" not found, the following services are available:"
+ else
+ echo "The following services are available:"
+ fi
+ for F in /etc/init.d/* ; do
+ printf "%-30s\t%10s\t%10s\n" "$F" \
+ $( $($F enabled) && echo "enabled" || echo "disabled" ) \
+ $( [ "$(ubus call service list "{ 'verbose': true, 'name': '$(basename $F)' }" \
+ | jsonfilter -q -e "@.$(basename $F).instances[*].running")" = "true" ] \
+ && echo "running" || echo "stopped" )
+ done;
return 1
- }
- /etc/init.d/$@
+ fi
}
[ -n "$KSH_VERSION" -o \! -s "$HOME/.shinit" ] || . "$HOME/.shinit"