Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Dec 2014 01:02:52 +0100
From:      Daniel Koester <dk.freebsd@hyve.org>
To:        freebsd-rc@freebsd.org
Subject:   service -R (restart) and [/usr/local]/etc/rc.conf.d/<name>
Message-ID:  <20141216000252.GB40862@dk.hyve.org>

next in thread | raw e-mail | index | archive | help
Hello FreeBSD-rc Readers,

this issue has left me confused now for quite some time and has
(for me) persisted since 8.* all the way up to 10.1-RELEASE-p1:

The rc system supports the '[/usr/local]/etc/rc.conf.d/' directory to
place small files, e.g. for '/etc/rc.conf.d/inetd' containing
'inetd_enable="YES"'. This works perfectly well at startup, i.e, at boot
time the system will actually start 'inetd', no problem there. However,
when calling 'service -e', '/etc/rc.d/inetd' will NOT be listed
(although it will be listed when calling 'service -l'). Furthermore, and
this is the root cause of this inquiry, 'service -R' will NOT stop and
start 'inetd', as one would expect it to do.
The bug tracker shows a few somewhat related bug reports, which are
mostly still open (some for years ;-), e.g.:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=173454
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=167822
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=141909

Each script in '[/usr/local]/etc/rc.d/' seems to call 'load_rc_config
$name' with '$name' properly set, so when using '/etc/rc.d/$name
<command>' everything works as expected.

Now, am I (ab)using the rc system in any wrong way or expecting a wrong
kind of behaviour from 'service -R', or might there be a bug. I looked
at '/usr/sbin/service' and noticed the following lines:

	. /etc/rc.subr
	load_rc_config 'XXX'

'load_rc_config' seems to search for a config file (also a directory) in
'/etc/rc.conf.d/XXX'. It seems the 'XXX' argument was simply used to
prevent the 'load_rc_config' call to exit with an error:

	ERROR: USAGE: load_rc_config name

Can we (ab)use this behaviour? Sure, we can, renaming 'inetd' to 'XXX'
in that directory works as expected, as does creating directory 'XXX'
and placing the 'inetd' file in there (in both cases, 'service -R'
restarts inetd and 'service -e' lists '/etc/rc.d/inetd').
Putting the line from the 'inetd' file into '/etc/rc.conf.local' also
works as expected...
Still, it would be nice to separate service configurations in
'/etc/rc.conf.d'.

I'm really sorry if this has been asked before, I searched for it on the
bug tracker and the mailing list search, but could not really find any
definitive answer as to the root cause of this behaviour or a suggested
fix (in my usage pattern).

So at this point either there's a bug somewhere (which I'm very much
willing to help fix), or I'm simply using it the wrong way (in which
case please feel obliged to correct me).
Maybe/hopefully somebody can chime in and help me...

Kind regards and keep up the awesome work,
DK



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141216000252.GB40862>