openwrt/package/system/procd/files/service
Andrew Ammerlaan a4af427d80 procd: service: pass all arguments to service
Passing all arguments to /etc/init.d/$service restores the
behaviour of openwrt 21.02. This is relevant for services
such as etherwake which take more then one argument, e.g.:
"service etherwake start <list of devices to wake>"

Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
(cherry picked from commit b2e83c16e1)
2022-11-27 15:43:08 +01:00

31 lines
716 B
Bash

#!/bin/sh
main() {
local service="$1"
shift
local boot status
if [ -f "/etc/init.d/${service}" ]; then
/etc/init.d/"${service}" "$@"
exit "$?"
fi
if [ -n "$service" ]; then
echo "Service \"$service\" 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 "$@"