init.d/local: bring functioning more in line with how sysctl works

- remove the has_executables variable since it isn't used.
- Convert the conditional calls to ewend/vewend to a single call to veend.
- Always call eend after all scripts are executed passing the appropriate
error code.

Because of this change, you will see only an overall status when
starting or stopping local unless you are using verbose mode.
This commit is contained in:
William Hubbs 2014-07-05 14:30:33 -05:00
parent c1de8c09bf
commit 57b9e601a9

View File

@ -14,20 +14,17 @@ start()
{ {
ebegin "Starting local" ebegin "Starting local"
local file has_errors retval local file has_errors=0 retval
eindent eindent
for file in @SYSCONFDIR@/local.d/*.start; do for file in @SYSCONFDIR@/local.d/*.start; do
if [ -x "${file}" ]; then if [ -x "${file}" ]; then
has_executables=1
vebegin "Executing \"${file}\"" vebegin "Executing \"${file}\""
"${file}" 2>&1 >/dev/null "${file}" 2>&1 >/dev/null
retval=$? retval=$?
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
has_errors=1 has_errors=1
ewend ${retval} "Execution of \"${file}\" failed."
else
vewend 0
fi fi
veend ${retval} "Execution of \"${file}\" failed."
fi fi
done done
eoutdent eoutdent
@ -40,9 +37,7 @@ start()
local_start local_start
fi fi
if [ -z "${has_errors}" ]; then eend ${has_errors}
eend 0
fi
# We have to end with a zero exit code, because a failed execution # We have to end with a zero exit code, because a failed execution
# of an executable @SYSCONFDIR@/local.d/*.start file shouldn't result in # of an executable @SYSCONFDIR@/local.d/*.start file shouldn't result in
@ -57,20 +52,17 @@ stop()
{ {
ebegin "Stopping local" ebegin "Stopping local"
local file has_errors retval local file has_errors=0 retval
eindent eindent
for file in @SYSCONFDIR@/local.d/*.stop; do for file in @SYSCONFDIR@/local.d/*.stop; do
if [ -x "${file}" ]; then if [ -x "${file}" ]; then
has_executables=1
vebegin "Executing \"${file}\"" vebegin "Executing \"${file}\""
"${file}" 2>&1 >/dev/null "${file}" 2>&1 >/dev/null
retval=$? retval=$?
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
has_errors=1 has_errors=1
ewend ${retval} "Execution of \"${file}\" failed."
else
vewend 0
fi fi
veend ${retval} "Execution of \"${file}\" failed."
fi fi
done done
eoutdent eoutdent
@ -83,9 +75,7 @@ stop()
local_stop local_stop
fi fi
if [ -z "${has_errors}" ]; then eend ${has_errors}
eend 0
fi
# An executable @SYSCONFDIR@/local.d/*.stop file which failed with a # An executable @SYSCONFDIR@/local.d/*.stop file which failed with a
# non-zero exit status is not a reason to mark this service # non-zero exit status is not a reason to mark this service