Re: Moving /etc/rc.conf.local to /usr/local/etc/rc.conf

From: Lowell Gilbert <freebsd-questions-local_at_be-well.ilk.org>
Date: Sat, 27 Jan 2024 23:01:44 UTC
Juan Manuel Palacios <jmpalacios@gmail.com> writes:

> I’ve read through the man page and /etc/defaults/rc.conf, and I still
> can’t figure out how to make rc(8) work with a /usr/local/etc/rc.conf
> file fully out-of-the-box. I did manage to configure each individual
> service that I want to start and customize through individual
> /usr/local/etc/rc.conf.d/$name configuration files, which is great, it
> does accomplish the goal I had of moving as many jail configurations
> as possible to /usr/local/etc; but, provided I’m reading things right,
> and /usr/local/etc/rc.conf is indeed not supported out-of-the-box, I
> wonder what the rationale for that would be, i.e. why support
> out-of-the-box /etc/rc.conf & /etc/rc.conf.local, rather than
> /etc/rc.conf & /usr/local/etc/rc.conf, which seems to be the FreeBSD
> standard used for almost everything else (e.g. /etc/pkg.conf &
> /usr/local/etc/pkg.conf for the pkg tool).
>
> I know you can customize the rc_conf_files variable to hold a value
> with my files of choice, but that in itself implies customizing
> /etc/rc.conf to override rc_conf_files’ default value, which defeats
> the purpose of keeping all customizations to /usr/local/etc.

For most people, it doesn't defeat that purpose. Keeping /etc the same
on all your machines is something plenty of people want to do, but
not putting anything into /etc/rc.conf is not by any means the only (or
even the obvious) way to do that.

It's quite common to have a shared /etc, but very uncommon to need that
to be limited to what an unscripted install would put in out of the
box. If you want this because you're applying a common template to
install a lot of machines, there is a common approach of scripting the
install to add the extra variable (or more) to /etc/rc.conf; they will
be customized, but they will all be customized in the same automated
way. You just change them all to have /usr/local/etc/rc.conf (your
choice of filename) included in ${rc_conf_files}.

That said, I don't see any reason that /etc/defaults/rc.conf couldn't
be modified in the official build to include a file in /usr/local into
${rc_conf_files} if said file exists. Make sure the filename isn't
likely to conflict with anything other people have already used, but
aside from that I don't see any downsides.

Be well.