Page MenuHomeFreeBSD

Including rc_conf_directories to be loaded with rc(8)
Needs ReviewPublic

Authored by on Jun 7 2018, 2:05 PM.
Referenced Files
F77761744: D15689.diff
Fri, Feb 23, 4:28 AM
Unknown Object (File)
Fri, Feb 16, 10:50 PM
Unknown Object (File)
Jan 24 2024, 12:29 AM
Unknown Object (File)
Jan 18 2024, 4:46 PM
Unknown Object (File)
Jan 17 2024, 3:58 PM
Unknown Object (File)
Jan 12 2024, 7:54 PM
Unknown Object (File)
Jan 9 2024, 1:35 PM
Unknown Object (File)
Dec 20 2023, 6:34 AM



rc.conf.d directories contains configuration files to be used at
boot time. This patch allows the user to write configuration files
under /etc/rc.conf.d and being loaded at boot time.

Test Plan

Create configuration files under /etc/rc.conf.d and rebooting to
see if they were loaded. Also changing the rc_conf_dirs to include
/usr/local/etc/rc.conf.d and repeat the process

Sponsored by: Bally Wulff Games & Entertainment GmbH

Diff Detail

rS FreeBSD src repository - subversion
Lint Passed
No Test Coverage
Build Status
Buildable 26587
Build 24971: arc lint + arc unit

Event Timeline

rpokala added inline comments.
711 ↗(On Diff #43409)

You're not actually using "sourced_dirs" anywhere.

714 ↗(On Diff #43409)

This will find files or directories named f; that's probably not what you intended...

(Perhaps you wanted find ${i} -type f?)

Removing unused variables and fixing find added inline comments.
714 ↗(On Diff #43409)

That's actually what I wanted, thanks

711 ↗(On Diff #43412)

Oh, do you need to declare d as a local? marked 3 inline comments as done.

Declaring d as local variable

Fixing problems and submitting comments

Exchanging i and d so d is for directories and i for files. Also including them

731 ↗(On Diff #43414)

Does the new stuff need to be repeated here? marked an inline comment as done.

Repeating the block to catch redefined rc_conf_dirs

Submitting commits

731 ↗(On Diff #43414)

I didn't thought to be needed, but if the variable is defined in the configuration files, it might be a good idea.

I think this looks good now. Now you can point someone who actually knows `rc' at it. :-)

dab added inline comments.
714 ↗(On Diff #43418)

You could save the nested for loops by doing:

for i in $(find ${rc_conf_dirs} -type f) ; do

714 ↗(On Diff #43418)

Do you actually want to do a recursive search through the rc_conf_dirs or limit the scope to just a first-level search? To be honest, I'm not sure of the "correct" answer to this, but rc only searches the first level in /etc/rc.d and /usr/local/rc.d for scripts to execute.

714 ↗(On Diff #43418)

Do you want to source all files found, or limit to a certain subset, such as only those files that end with ".conf"? I think there is precedent for both. Also, should "dot" files (e.g., /etc/rc.conf.d/.example.conf) be excluded?

714 ↗(On Diff #43418)

OK, I think this is my last comment (for now, at least).

Do you want to find and source the files in lexicographic order so that someone could, for example, ensure that /etc/rc.conf.d/00-local.conf was sourced before /etc/rc.conf.d/99-local.conf?

Adding inline comments to figure out the best way to proceed.

714 ↗(On Diff #43418)

could it be done like this?

for i in $(find -s ${rc_conf_dirs} -type f -depth 1 -name '*.conf' -and -not -name '.*') ; do

Searching only on the first level makes sense, they are a collection of configuration files and, in the case that the user wants to sort them out in folders, they can be searched by overriding the rc_conf_dirs variable.

It also makes sense to sort them out in lexicographic order. added a subscriber: brooks.

Adding @brooks because he is in the subversion's property $FreeBSD$

714 ↗(On Diff #43418)

Yes, I think that will do it. marked 2 inline comments as done.

Limiting search to immediates files named '*.conf' not starting with a dot

0mp requested changes to this revision.Jul 31 2019, 3:56 PM
  1. I'd think that files in rc.conf.d should override what is in $rc_conf_files as they are more specific. Is there a reason why you'd like $rc_conf_files to be able to override files in rc.conf.d instead?
  2. This change deserves an update to the manual page.
705 ↗(On Diff #43457)

This comment might require an update to mention rc_conf_dirs as well.

713 ↗(On Diff #43457)

-depth 1 should be -maxdepth 1. Otherwise, find(1) is going to iterate over all the subdirectories anyway.

730 ↗(On Diff #43457)

-depth 1 should be -maxdepth 1. Otherwise, find(1) is going to iterate over all the subdirectories anyway.

This revision now requires changes to proceed.Jul 31 2019, 3:56 PM

Updating the script with the new location and including the changes proposed by 0mp


BTW, find lives in /usr/bin. For what I understand, it may not be available before /usr/ is mounted.