svn commit: r316487 - head/etc
Cy Schubert
Cy.Schubert at komquats.com
Wed Apr 5 03:05:36 UTC 2017
In message <201704041143.v34BhVNA046204 at repo.freebsd.org>,
=?UTF-8?Q?Dag-Erling
_Sm=c3=b8rgrav?= writes:
> Author: des
> Date: Tue Apr 4 11:43:31 2017
> New Revision: 316487
> URL: https://svnweb.freebsd.org/changeset/base/316487
>
> Log:
> Allow command modifiers (fast, quiet etc.) to be stacked in any order.
> Add a "debug" modifier that sets rc_debug.
>
> MFC after: 3 weeks
>
> Modified:
> head/etc/rc.subr
>
> Modified: head/etc/rc.subr
> =============================================================================
> =
> --- head/etc/rc.subr Tue Apr 4 08:17:03 2017 (r316486)
> +++ head/etc/rc.subr Tue Apr 4 11:43:31 2017 (r316487)
> @@ -703,10 +703,11 @@ check_startmsgs()
> # If argument has a given prefix, then change the operation as follows:
> # Prefix Operation
> # ------ ---------
> -# fast Skip the pid check, and set rc_fast=yes, rc_quiet=yes
> -# force Set ${rcvar} to YES, and set rc_force=yes
> -# one Set ${rcvar} to YES
> -# quiet Don't output some diagnostics, and set rc_quiet=yes
> +# debug Enable debugging messages and set rc_debug to yes
> +# fast Skip the pid check and set rc_fast and rc_quiet to yes
> +# force Skip sanity checks and set ${rcvar} and rc_force to yes
> +# one Set ${rcvar} and set rc_one to yes
> +# quiet Don't output some diagnostics, and set rc_quiet to yes
> #
> # The following globals are used:
> #
> @@ -856,6 +857,8 @@ check_startmsgs()
> # rc_arg Argument to command, after fast/force/one processing
> # performed
> #
> +# rc_debug True if "debug" was provided
> +#
> # rc_flags Flags to start the default command with.
> # Defaults to ${name}_flags, unless overridden
> # by $flags from the environment.
> @@ -863,9 +866,11 @@ check_startmsgs()
> #
> # rc_pid PID of command (if appropriate)
> #
> -# rc_fast Not empty if "fast" was provided (q.v.)
> +# rc_fast Not empty if "fast" was provided
> +#
> +# rc_force Not empty if "force" was provided
> #
> -# rc_force Not empty if "force" was provided (q.v.)
> +# rc_one Not empty if "one" was provided
> #
> # rc_quiet Not empty if "quiet" was provided
> #
> @@ -884,34 +889,47 @@ run_rc_command()
> shift 1
> rc_extra_args="$*"
>
> - _rc_prefix=
> - case "$rc_arg" in
> - fast*) # "fast" prefix; don't check pid
> - rc_arg=${rc_arg#fast}
> - rc_fast=yes
> - rc_quiet=yes
> - ;;
> - force*) # "force" prefix; always run
> - rc_force=yes
> - _rc_prefix=force
> - rc_arg=${rc_arg#${_rc_prefix}}
> - if [ -n "${rcvar}" ]; then
> - eval ${rcvar}=YES
> - fi
> - ;;
> - one*) # "one" prefix; set ${rcvar}=yes
> - _rc_prefix=one
> - rc_arg=${rc_arg#${_rc_prefix}}
> + : ${rc_debug:=no} ${rc_fast:=no} ${rc_force:=no} ${rc_one:=no} ${rc_qui
> et:=no}
> + while :; do
> + case "$rc_arg" in
> + debug*) # "debug" prefix; enable debugging
> + rc_debug=yes
> + rc_quiet=no
> + rc_arg=${rc_arg#debug}
> + _rc_prefix="${_rc_prefix}debug"
> + ;;
> + fast*) # "fast" prefix; don't check pid
> + rc_fast=yes
> + rc_quiet=yes
> + rc_arg=${rc_arg#fast}
> + _rc_prefix="${_rc_prefix}fast"
> + ;;
> + force*) # "force" prefix; always run
> + rc_force=yes
> + rc_arg=${rc_arg#force}
> + _rc_prefix="${_rc_prefix}force"
> + ;;
> + one*) # "one" prefix; set ${rcvar}=yes
> + rc_one=yes
> + rc_arg=${rc_arg#one}
> + _rc_prefix="${_rc_prefix}one"
> + ;;
> + quiet*) # "quiet" prefix; omit some messages
> + rc_quiet=yes
> + rc_arg=${rc_arg#quiet}
> + _rc_prefix="${_rc_prefix}quiet"
> + ;;
> + *)
> + break
> + ;;
> + esac
> + done
> + if checkyesno rc_force || checkyesno rc_one ; then
> if [ -n "${rcvar}" ]; then
> eval ${rcvar}=YES
> fi
> - ;;
> - quiet*) # "quiet" prefix; omit some messages
> - _rc_prefix=quiet
> - rc_arg=${rc_arg#${_rc_prefix}}
> - rc_quiet=yes
> - ;;
> - esac
> + fi
> + debug "_rc_prefix=${_rc_prefix}"
>
> eval _override_command=\$${name}_program
> command=${_override_command:-$command}
>
>
Hi des,
This patch caused some boot failures because the contents of rc_force were
redefined from "yes" (for yes) and NULL (for no) to the words "yes" and
"no". This in turn caused etc/rc.d/dhclient to assume force when $rc_force
was not NULL (test -z failed). Interfaces with static IP addresses invoked
rc.d/dhclient through devd. The attached patch should make all instances
$rc_force consistent with your change.
-------------- next part --------------
Index: rc.d/bgfsck
===================================================================
--- rc.d/bgfsck (revision 316487)
+++ rc.d/bgfsck (working copy)
@@ -26,7 +26,7 @@
bgfsck_start()
{
: ${background_fsck_delay=0}
- if [ -n "${rc_force}" ]; then
+ if checkyesno rc_force; then
background_fsck_delay=0
fi
if [ ${background_fsck_delay} -lt 0 ]; then
@@ -38,7 +38,7 @@
if [ "${background_fsck_delay}" -gt 0 ]; then
bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
fi
- if [ -z "${rc_force}" ]; then
+ if ! checkyeno rc_force; then
check_startmsgs && echo "${bgfsck_msg}."
fi
Index: rc.d/dhclient
===================================================================
--- rc.d/dhclient (revision 316487)
+++ rc.d/dhclient (working copy)
@@ -22,7 +22,7 @@
# time, so we're testing it in the pre* hooks.
dhclient_pre_check()
{
- if [ -z "${rc_force}" ] && ! dhcpif $ifn; then
+ if ! checkyesno rc_force && ! dhcpif $ifn; then
local msg
msg="'$ifn' is not a DHCP-enabled interface"
if [ -z "${rc_quiet}" ]; then
Index: rc.subr
===================================================================
--- rc.subr (revision 316487)
+++ rc.subr (working copy)
@@ -1156,7 +1156,7 @@
( run_rc_command ${_rc_prefix}stop $rc_extra_args )
( run_rc_command ${_rc_prefix}start $rc_extra_args )
_return=$?
- [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1
+ [ $_return -ne 0 ] && ! checkyesno rc_force && return 1
_run_rc_postcmd
;;
@@ -1268,7 +1268,7 @@
_return=$?
# If precmd failed and force isn't set, request exit.
- if [ $_return -ne 0 ] && [ -z "$rc_force" ]; then
+ if [ $_return -ne 0 ] && ! checkyesno rc_force; then
return 1
fi
fi
@@ -1295,7 +1295,7 @@
_return=$?
# If command failed and force isn't set, request exit.
- if [ $_return -ne 0 ] && [ -z "$rc_force" ]; then
+ if [ $_return -ne 0 ] && ! checkyesno rc_force; then
return 1
fi
@@ -2011,7 +2011,7 @@
for _f in $required_vars; do
if ! checkyesno $_f; then
warn "\$${_f} is not enabled."
- if [ -z "$rc_force" ]; then
+ if ! checkyesno $rc_force; then
return 1
fi
fi
@@ -2020,7 +2020,7 @@
for _f in $required_dirs; do
if [ ! -d "${_f}/." ]; then
warn "${_f} is not a directory."
- if [ -z "$rc_force" ]; then
+ if ! checkyesno $rc_force; then
return 1
fi
fi
@@ -2029,7 +2029,7 @@
for _f in $required_files; do
if [ ! -r "${_f}" ]; then
warn "${_f} is not readable."
- if [ -z "$rc_force" ]; then
+ if ! checkyesno $rc_force; then
return 1
fi
fi
@@ -2053,7 +2053,7 @@
*) _args="${_f}" ;;
esac
if ! load_kld ${_args}; then
- if [ -z "$rc_force" ]; then
+ if ! checkyesno rc_force; then
return 1
fi
fi
-------------- next part --------------
Cheers,
Cy Schubert <Cy.Schubert at cschubert.com>
FreeBSD UNIX: <cy at FreeBSD.org> Web: http://www.FreeBSD.org
The need of the many outweighs the greed of the few.
More information about the svn-src-all
mailing list