diff options
-rw-r--r-- | src.etc/rc.common | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src.etc/rc.common b/src.etc/rc.common index 344e3e7..e495e1c 100644 --- a/src.etc/rc.common +++ b/src.etc/rc.common @@ -11,21 +11,22 @@ set -u SCRIPT='' +ALL_CMDS='' LOG_MSG='' EXTRA_COMMANDS='' main() { local action="${2}" - local all_cmds= local es= SCRIPT="${1}" . "${SCRIPT}" - all_cmds=" start stop restart ${EXTRA_COMMANDS} " - if [ "x${all_cmds#* ${action} }" != "x${all_cmds}" ]; then + ALL_CMDS=" start stop restart ${EXTRA_COMMANDS} " + + if [ "x${ALL_CMDS#* ${action} }" != "x${ALL_CMDS}" ]; then ${action} es=${?} log_end ${es} @@ -42,13 +43,10 @@ tty_printf() } usage() { - local cmd= + local cmds= - tty_printf 'Usage: %s {start|stop|restart' "${SCRIPT}" - if [ "x${EXTRA_COMMANDS:+set}" = 'xset' ]; then - tty_printf '|%s' ${EXTRA_COMMANDS} - fi - tty_printf '}\n' + cmds="$(printf '%s|' ${ALL_CMDS})" + tty_printf 'Usage: %s {%s}\n' "${SCRIPT}" "${cmds%|}" } log() |