[ -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"