Punt is_function in favour of POSIX shell builtin command, thanks to Harald van Dijk for the idea.
This commit is contained in:
@@ -94,7 +94,7 @@ unset _f
|
||||
|
||||
# If we have a default command then supply a default start function
|
||||
if [ -n "${command}" ]; then
|
||||
if ! is_function start; then
|
||||
if ! [ "$(command -v start)" != "start" ]; then
|
||||
start() {
|
||||
local _background=
|
||||
ebegin "Starting ${name:-${RC_SVCNAME}}"
|
||||
@@ -126,7 +126,7 @@ fi
|
||||
# If we have a default command, procname or pidfile then supply a default stop
|
||||
# function
|
||||
if [ -n "${command}" -o -n "${procname}" -o -n "${pidfile}" ]; then
|
||||
if ! is_function stop; then
|
||||
if ! [ "$(command -v stop)" != "stop" ]; then
|
||||
stop() {
|
||||
ebegin "Stopping ${name:-${RC_SVCNAME}}"
|
||||
start-stop-daemon --stop \
|
||||
@@ -143,7 +143,7 @@ while [ -n "$1" ]; do
|
||||
for _cmd in describe start stop ${extra_commands:-${opts}} \
|
||||
${extra_started_commands}; do
|
||||
if [ "${_cmd}" = "$1" ]; then
|
||||
if is_function "$1"; then
|
||||
if [ "$(command -v "$1")" = "$1" ]; then
|
||||
# If we're in the background, we may wish to
|
||||
# fake some commands. We do this so we can
|
||||
# "start" ourselves from inactive which then
|
||||
@@ -168,11 +168,11 @@ while [ -n "$1" ]; do
|
||||
fi
|
||||
done
|
||||
unset _cmd
|
||||
if is_function "$1"_pre >/dev/null 2>&1; then
|
||||
if [ "$(command -v "$1_pre")" = "$1_pre" ]; then
|
||||
"$1"_pre || exit $?
|
||||
fi
|
||||
"$1" || exit $?
|
||||
if is_function "$1"_post >/dev/null 2>&1; then
|
||||
if [ "$(command -v "$1_post")" = "$1_post" ]; then
|
||||
"$1"_post || exit $?
|
||||
fi
|
||||
shift
|
||||
|
||||
Reference in New Issue
Block a user