We should check type output to ensure that we're really calling a shell function and not some badly named binary like stop from boinc, Gentoo #218063.

This commit is contained in:
Roy Marples
2008-04-18 23:00:43 +00:00
parent f0aacec02e
commit e96347523f
3 changed files with 29 additions and 20 deletions

View File

@@ -94,7 +94,7 @@ unset _f
# If we have a default command then supply a default start function
if [ -n "${command}" ]; then
if ! type start >/dev/null 2>&1; then
if ! is_function 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 ! type stop >/dev/null 2>&1; then
if ! is_function 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 type "$1" >/dev/null 2>&1; then
if is_function "$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 type "$1"_pre >/dev/null 2>&1; then
if is_function "$1"_pre >/dev/null 2>&1; then
"$1"_pre || exit $?
fi
"$1" || exit $?
if type "$1"_post >/dev/null 2>&1; then
if is_function "$1"_post >/dev/null 2>&1; then
"$1"_post || exit $?
fi
shift