aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/etc/rc.common
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files/files/etc/rc.common')
-rwxr-xr-xpackage/base-files/files/etc/rc.common38
1 files changed, 24 insertions, 14 deletions
diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
index 7c11544405..d3d91ef250 100755
--- a/package/base-files/files/etc/rc.common
+++ b/package/base-files/files/etc/rc.common
@@ -62,20 +62,24 @@ depends() {
return 0
}
+EXTRA_HELP=""
+EXTRA_COMMANDS="boot shutdown depends"
+extra_command() {
+ local cmd="$1"
+ local help="$2"
+
+ local extra="$(printf "%-16s%s" "${cmd}" "${help}")"
+ EXTRA_HELP="${EXTRA_HELP}\t${extra}\n"
+ EXTRA_COMMANDS="${EXTRA_COMMANDS} ${cmd}"
+}
+
help() {
cat <<EOF
Syntax: $initscript [command]
Available commands:
- start Start the service
- stop Stop the service
- restart Restart the service
- reload Reload configuration files (or restart if service does not implement reload)
- enable Enable service autostart
- disable Disable service autostart
- enabled Check if service is started on boot
-$EXTRA_HELP
EOF
+ echo -e "$EXTRA_HELP"
}
# for procd
@@ -103,14 +107,20 @@ service_running() {
${INIT_TRACE:+set -x}
+extra_command "start" "Start the service"
+extra_command "stop" "Stop the service"
+extra_command "restart" "Restart the service"
+extra_command "reload" "Reload configuration files (or restart if service does not implement reload)"
+extra_command "enable" "Enable service autostart"
+extra_command "disable" "Disable service autostart"
+extra_command "enabled" "Check if service is started on boot"
+
. "$initscript"
[ -n "$USE_PROCD" ] && {
- EXTRA_COMMANDS="${EXTRA_COMMANDS} running status trace"
- EXTRA_HELP="\
- running Check if service is running
- status Service status
-${EXTRA_HELP}"
+ extra_command "running" "Check if service is running"
+ extra_command "status" "Service status"
+ extra_command "trace" "Start with syscall trace"
. $IPKG_INSTROOT/lib/functions/procd.sh
basescript=$(readlink "$initscript")
@@ -165,6 +175,6 @@ ${EXTRA_HELP}"
}
}
-ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
+ALL_COMMANDS="${EXTRA_COMMANDS}"
list_contains ALL_COMMANDS "$action" || action=help
$action "$@"