sysrc(8) syntax question for temporary overrides of /etc/rc.conf values

What syntax do I need to use to tell sysrc(8) what I mean?

Code:
jimsdesk : 13:32:36 # sysrc -f /etc/rc.conf rc_conf_files='/etc/rc.conf /etc/rc.conf.local /etc/rc.conf.d/*.conf'
rc_conf_files: /etc/rc.conf /etc/rc.conf.local -> /etc/rc.conf /etc/rc.conf.local

Anything I try seems to drop the wildcard /etc/rc.conf.d/*.conf. I realize there are no files there now, but maybe there will be tomorrow. And upon deeper reflection, there is a *.conf file there presently.

How can I tell sysrc to include /etc/rc.conf.d/*.conf in rc_conf_files?
 
a) Using sh(1) I cannot confirm any issue. It appears your shell expanded the glob(3) pattern even though it’s in single quotes. Try touch /etc/rc.conf.d/foobar.conf and re‑issue the sysrc(8) command to verify this hypothesis.

b) You are using rc_conf_files and /etc/rc.conf.d wrong. The variable is meant to hold full pathnames, the directory is supposed to contain 〈service_name〉 files, review rc.conf(5).​
 
Code:
# touch /etc/rc.conf.d/foobar.conf
# sysrc -f /etc/rc.conf rc_conf_files='/etc/rc.conf /etc/rc.conf.local /etc/rc.conf.d/*.conf'
rc_conf_files: /etc/rc.conf /etc/rc.conf.local -> /etc/rc.conf /etc/rc.conf.local
# sysrc -f /etc/rc.conf rc_conf_files
rc_conf_files: /etc/rc.conf /etc/rc.conf.local
 
Have you tried double quotes (name="value")?

Besides that, there is no need to define those rc_conf_files specifically, they are specified anyway by default.

/etc/defaults/rc.conf
Rich (BB code):
rc_conf_files="/etc/rc.conf /etc/rc.conf.local"

Furthermore, as mentioned already, <name> in /etc/rc.conf.d/<name> must be a service name from /etc/rc.d/ (or /usr/local/etc/rc.d/) as file name (see "rc(8) script" in manual down below), but can also be a directory for files located underneath (see last highlighted paragraph of the excerpt from the manual and "Examples"). In short, all the desired configurations you want are already been set by default.

rc.conf(5)
Rich (BB code):
     ...
     In addition to /etc/rc.conf.local you can also place smaller
     configuration files for each rc(8) script in the /etc/rc.conf.d directory
     or ⟨dir⟩/rc.conf.d directories (where ⟨dir⟩ is each entry specified in
     local_startup, but with any trailing /rc.d stripped), which will be
     included by the load_rc_config function.  For jail configurations you
     could use the file /etc/rc.conf.d/jail to store jail-specific
     configuration options.  If local_startup contains /usr/local/etc/rc.d and
     /opt/conf, /usr/local/etc/rc.conf.d/jail and /opt/conf/rc.conf.d/jail
     will be loaded.  If ⟨dir⟩/rc.conf.d/⟨name⟩ is a directory then all of the
     files in the directory will be loaded.  See also the rc_conf_files
     variable below.

Examples:

"ntpd" is a file /etc/rc.conf.d/ntpd
Code:
ntpd_enable="YES"

"ntpd" is a directory /etc/rc.conf.d/ntpd/nptd.conf
Code:
ntpd_enable="YES"

Code:
% ls /etc/rc.d/ntpd
/etc/rc.d/ntpd
 
What I'd like to achieve is to have a file-based mechanism to be able to temporarily override any given setting in
/etc/rc.conf by placing an arbitrarily named file (but matching *.conf, and lexical ordering is expected) into
/etc/rc.conf.d/. I was hoping that such files would be read after /etc/defaults/rc.conf and /etc/rc.conf itself, so that defaults specified in /etc/defaults/rc.conf would be overridden by settings in /etc/rc.conf, which in turn would be overridden by settings in /etc/rc.conf.d/*.conf. I'm fine with service-specific setting overrides being placed in /etc/rc.conf.d/(service) but I'm puzzled as to why (indeed, whether) files /etc/rc.conf.d/*.conf are verboten. Speaking lazily, it seems a bit of a high bar for a script to have to discern, based only on the variable name being set, which directory /etc/rc.conf.d/(service) the override must appear. And this doesn't even touch on /etc/rc.conf settings which are not service-related.

To pose the question directly, what are files /etc/rc.conf.d/*.conf for?

Thank you to all who are watching this thread, and please don't misconstrue my tone; I am asking both from a standpoint of edification, and also the viability or lack thereof of this idea, if it is truly novel. If sysrc(8) had the ability to "push" and "pop" values that might well suffice for my purposes, such that a "push" would override a value, and a "pop" would restore the previous value, without the (my) script having to modify/make a backup of/monkey with /etc/rc.conf. To my knowledge though, sysrc(8) has no such functionality.

My goal to e.g. temporarily set rc_debug, and subsequently restore its previous value would be:

Code:
# force rc_debug to be true:
sysrc -f /etc/rc.conf.d/99_temp_rc_debug rc_debug=yes
# ... do whatever is needed, possibly across several reboots
# when finished, remove temp override and revert rc_debug to its previous value:
rm -f /etc/rc.conf.d/99_temp_rc_debug

To accomplish this via the /etc/rc.conf.d/(service) model, what service does rc_debug belong to? And given that services are generally started late-ish, wouldn't I lose rc_debug output from the earlier phases of the init process?

Thanks again for your time and critiques.
 
How about creating your temporary rc.conf variable in /etc/rc.conf.local ?

It looks like /etc/rc.conf.local is parsed after /etc/rc.conf, so any settings in rc.conf.local should temporarily override anything in /etc/rc.conf.
 
Use the source, Luke. I suggest reading the script /etc/rc.subr. It has all the functions and logic that is used by the various rc(8) scripts. In your case you should probably have a look at the load_rc_config() function and its logic.

Code:
#
# load_rc_config [service]
#       Source in the configuration file(s) for a given service.
#       If no service is specified, only the global configuration
#       file(s) will be loaded.
#
load_rc_config()
 
Back
Top