rc.subr: don't require service to be enabled for status

For a service that sets an rcvar, there is a check whether it has been
enabled before the actual command is executed. If the check fails, one
gets a message to enable it and the returned exit status is 0.
However, this is usually undesirable for the status command, which is
a) supposed to check whether the service is running anyway and
b) returns a non-zero exit code if that is not the case.
Thus, skip the check for the status command.

PR:		272282
Reviewed by:	emaste

(cherry picked from commit ba793728a8)
This commit is contained in:
Daniel Tameling 2023-07-01 10:43:40 +02:00 committed by Ed Maste
parent be31bd5989
commit f701d9da1d

View file

@ -1041,13 +1041,14 @@ run_rc_command()
continue
fi
# if ${rcvar} is set, $1 is not "rcvar", "describe",
# "enable" or "delete", and ${rc_pid} is not set, run:
# "enable", "delete" or "status", and ${rc_pid} is
# not set, run:
# checkyesno ${rcvar}
# and return if that failed
#
if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != "stop" \
-a "$rc_arg" != "delete" -a "$rc_arg" != "enable" \
-a "$rc_arg" != "describe" ] ||
-a "$rc_arg" != "describe" -a "$rc_arg" != "status" ] ||
[ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
if ! checkyesno ${rcvar}; then
if [ -n "${rc_quiet}" ]; then