forked from openwrt/openwrt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
3 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |