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.