]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Resurrect set_rcvar() as a function to define a rc.conf variable.
authorhrs <hrs@FreeBSD.org>
Thu, 2 Oct 2014 01:16:30 +0000 (01:16 +0000)
committerhrs <hrs@FreeBSD.org>
Thu, 2 Oct 2014 01:16:30 +0000 (01:16 +0000)
commitfd6a7f8ca9a6e8a5ad987094edf77b876f3e7284
tree2bad489a106f18af68d5d83feb875da64a551149
parent43ddffd06b348b7fa747a97c4d2dfc6d4ef1ff46
Resurrect set_rcvar() as a function to define a rc.conf variable.
It defines a variable and its default value in load_rc_config() just after
rc.conf is loaded.  "rcvar" command shows the current and the default values.

This is an attempt to solve a problem that rc.d scripts from third-party
software do not have entries in /etc/defaults/rc.conf.  The fact that
load_rc_config() reads rc.conf only once and /etc/rc invokes the function
before running rc.d scripts made developers confused for a long time because
load_rc_config() just before run_rc_command() in each rc.d script overrides
variables only when the script is directly invoked, not from /etc/rc.

Variables defined in set_rcvar are always set in load_rc_config() after
loading rc.conf.  An rc.d script can now be written in a self-contained
manner regarding the related variables as follows:

---
name=foo
rcvar=foo_enable

set_rcvar foo_enable YES "Enable $name"
set_rcvar foo_flags "-s" "Flags to $name"

...

load_rc_config $name
run_rc_command "$@"
---
etc/rc.subr