2021-11-30 15:01:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
main() {
|
|
|
|
local service="$1"
|
2022-10-30 14:56:14 +00:00
|
|
|
shift
|
2021-11-30 15:01:14 +00:00
|
|
|
|
|
|
|
local boot status
|
|
|
|
|
|
|
|
if [ -f "/etc/init.d/${service}" ]; then
|
2022-10-30 14:56:14 +00:00
|
|
|
/etc/init.d/"${service}" "$@"
|
2021-11-30 15:01:14 +00:00
|
|
|
exit "$?"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$service" ]; then
|
2022-10-30 14:56:14 +00:00
|
|
|
echo "Service \"$service\" not found:"
|
2021-11-30 15:01:14 +00:00
|
|
|
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 "$@"
|