Page MenuHomeFreeBSD

sysrc: Add support for ``rc.conf.d'' service(8) configuration file(s)
ClosedPublic

Authored by dteske on Sep 2 2015, 7:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 23, 6:02 AM
Unknown Object (File)
Mon, Apr 8, 6:05 AM
Unknown Object (File)
Sun, Apr 7, 10:19 PM
Unknown Object (File)
Sun, Apr 7, 9:33 PM
Unknown Object (File)
Thu, Mar 28, 10:36 PM
Unknown Object (File)
Thu, Mar 28, 5:54 AM
Unknown Object (File)
Tue, Mar 26, 11:33 PM
Unknown Object (File)
Feb 15 2024, 1:44 PM

Details

Summary

Add sysrc(8) support for "rc.conf.d" file(s) when given "-s name" to
indicate service(8) script. While here, add "-l" option for listing the
set of configuration file(s) considered (in order; separated by space).
Also add "-L" for exploring all configuration files and "-E" to omit
files that don't exist from operations.

Test Plan

Check that "-L name" lists "rc.conf.d" entries for named "rc.d" script:

$ sysrc -L ipfw

/etc/rc.conf.d/ipfw /usr/local/etc/rc.conf.d/ipfw

$ sysrc -L dhclient

/etc/rc.conf.d/dhclient /usr/local/etc/rc.conf.d/dhclient \
/etc/rc.conf.d/network /usr/local/etc/rc.conf.d/network

$ sysrc -L nosuchservice

(no output)

Check that "-ls name" lists "rc.conf" and "rc.conf.d" entries:

$ sysrc -ls ipfw

/etc/rc.conf /etc/rc.conf.local \
/etc/rc.conf.d/ipfw /usr/local/etc/rc.conf.d/ipfw

$ sysrc -ls dhclient

/etc/rc.conf /etc/rc.conf.local \
/etc/rc.conf.d/dhclient /usr/local/etc/rc.conf.d/dhclient \
/etc/rc.conf.d/network /usr/local/etc/rc.conf.d/network

$ sysrc -ls nosuchservice

/etc/rc.conf /etc/rc.conf.local

Check that "-l" lists "rc.conf" entries:

$ sysrc -l

/etc/rc.conf /etc/rc.conf.local

Check that "-lD" lists the default rc.conf:

/etc/defaults/rc.conf

Check that "-s name variable" is able to get settings from "rc.conf.d":

$ sysrc -f /etc/rc.conf.d/ipfw foo=bar

foo: -> bar

$ sysrc -s ipfw foo

foo: bar

$ sysrc -Fs ipfw foo
foo: /etc/rc.conf.d/ipfw

Check that "-s name variable=value" is able to put settings in "rc.conf.d":

$ sysrc -vs ipfw bar=baz

/etc/rc.conf.d/ipfw: bar: -> baz

Check that "-L" produces a list of all usable configuration files:

$ sysrc -L

(long output)

Check that "-Lv" produces a list of services and their configuration files:

$ sysrc -Lv

(long output)

Check that "-EL" produces a list of existing configuration files:

$ sysrc -Lv

(depends on system)

Check that "-ELv" shows all existing configuration files and what uses them:

$ sysrc -ELv

(depends on system)

Check that "-qL ipfw" returns success:

$ sysrc -qL ipfw && echo found

found

Check that "-qL xxx" returns failure:
$ sysrc -qL xxx || echo not found

not found

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dteske retitled this revision from to sysrc: Add support for ``rc.conf.d'' service(8) configuration file(s).
dteske updated this object.
dteske edited the test plan for this revision. (Show Details)
dteske added reviewers: allanjude, bapt, eadler, delphij.
dteske added subscribers: allanjude, bdrewery, bapt.
dteske edited edge metadata.

Fix code typo preventing local_startup based rc.conf.d entries

dteske edited edge metadata.

Add support for `rc.conf.d/$name' as a directory.

Can we add some unit tests, please?

Can we add some unit tests, please?

Did you see the "Test Plan" section in this review? Or did you mean a test harness?

In D3551#73903, @dteske wrote:

Can we add some unit tests, please?

Did you see the "Test Plan" section in this review? Or did you mean a test harness?

Tests should be in the source tree, IMO.

usr.sbin/bsdconfig/share/sysrc.subr
248 ↗(On Diff #8438)

rcNG allows /etc/rc.conf.d/<service>/* as well

rc.subr does it this way:

for _d in /etc ${local_startup}; do
        _d=${_d%/rc.d}
        if [ -f ${_d}/rc.conf.d/"$_name" ]; then
                debug "Sourcing ${_d}/rc.conf.d/$_name"
                . ${_d}/rc.conf.d/"$_name"
        elif [ -d ${_d}/rc.conf.d/"$_name" ] ; then
                local _rc
                for _rc in ${_d}/rc.conf.d/"$_name"/* ; do
                        if [ -f "$_rc" ] ; then
                                debug "Sourcing $_rc"
                                . "$_rc"
                        fi
                done
        fi
done
allanjude edited edge metadata.
allanjude added inline comments.
usr.sbin/bsdconfig/share/sysrc.subr
248 ↗(On Diff #8438)

nevermind, you already addressed this

This revision is now accepted and ready to land.Sep 9 2015, 2:37 AM

More to come

dteske edited edge metadata.

Add -E' for "Existing Only" and -L' for "List all".
Update usage and help statements.
Change -l' and -s name' handling for robustness.
Produce usage if arguments are given to `-l'.
More manual updates.

dteske edited the test plan for this revision. (Show Details)
dteske edited edge metadata.
dteske edited the test plan for this revision. (Show Details)
dteske updated this object.
dteske updated this object.

Support -q' with -L [name ...]' and minor manual update

dteske edited edge metadata.

Still a little more to do; I'd like to add more to the manual page with respect to examples using -l and -L. For instance, documenting "sysrc -ELv" is very important, as it's a quick way to get a list of all configuration files that exist and which services use them.

ETIMEOUT for additional reviewers

This revision was automatically updated to reflect the committed changes.

Committed to stable/10 as SVN r292833