History log of /freebsd-10.0-release/etc/rc.subr
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 256256 10-Oct-2013 hrs

- Update rc.d/jail to use a jail(8) configuration file instead of
command line options. The "jail_<jname>_*" rc.conf(5) variables for
per-jail configuration are automatically converted to
/var/run/jail.<jname>.conf before the jail(8) utility is invoked.
This is transparently backward compatible.

- Fix a minor bug in jail(8) which prevented it from returning false
when jail -r failed.

Approved by: re (glebius)


# 255809 23-Sep-2013 des

Add a setup script for unbound(8) called local-unbound-setup. It
generates a configuration suitable for running unbound as a caching
forwarding resolver, and configures resolvconf(8) to update unbound's
list of forwarders in addition to /etc/resolv.conf. The initial list
is taken from the existing resolv.conf, which is rewritten to point to
localhost. Alternatively, a list of forwarders can be provided on the
command line.

To assist this script, add an rc.subr command called "enabled" which
does nothing except return 0 if the service is enabled and 1 if it is
not, without going through the usual checks. We should consider doing
the same for "status", which is currently pointless.

Add an rc script for unbound, called local_unbound. If there is no
configuration file, the rc script runs local-unbound-setup to generate
one.

Note that these scripts place the unbound configuration files in
/var/unbound rather than /etc/unbound. This is necessary so that
unbound can reload its configuration while chrooted. We should
probably provide symlinks in /etc.

Approved by: re (blanket)


# 248820 28-Mar-2013 avg

rc.subr: disabling globbing while processing devfs rules

The rules themselves typically have shell-like patterns and it is
incorrect when they get replaced with matching filesystem entries.

Shell magic by: jilles
MFC after: 2 weeks


# 245250 10-Jan-2013 smh

Allow perl scripts to be used in rc.d scripts

PR: conf/117027
Reviewed by: pjd (mentor)
Approved by: hrs
MFC after: 2 weeks


# 243324 20-Nov-2012 hrs

Do not put "already running" message when rc_quiet=yes.

PR: bin/165477


# 243184 17-Nov-2012 hrs

Add check_namevarlist() to check if ${name}_var is reserved in rc.subr or not.


# 242184 27-Oct-2012 hrs

Add setfib(1) support for services as <name>_fib in rc.conf.


# 242183 27-Oct-2012 crees

Allow spaces in _chroot

Noticed by: adj (IRC/#bsdports)
Approved by: hrs
MFC after: 1 month


# 238416 13-Jul-2012 kevlo

Whitespace nit


# 231888 17-Feb-2012 delphij

Put the signal trap output to standard error instead of standard output.
Without this change, pressing ^T could result in rc.d script putting
junk strings like:

Script <filename> running

in configuration files when redirecting standard output to these files.

MFC after: 2 weeks


# 231667 14-Feb-2012 dougb

Fix various issues with the NFS and RPC related scripts:

1. Add new functionality to the force_depend method to incorporate the
tests for whether the service is enabled and/or already running.
2. Add a new option to bypass checking only that the service is enabled
at boot time, and always check if it is running.
3. Use this new functionality to greatly simplify the rc.d scripts that
use force_depend.
4. Add a force_depend for statd in lockd
5. Remove the check that either nfs_server or nfs_client is _enable'd
from statd and lockd. This was always overkill, and prevented using
the {one|force}start options, as well as stop'ing on the command line.
6. The yp* scripts had some of their arguments in various weird orders.
Bring them into line with the model.
7. If mountd fails to create /var/db/mountdtab, err out.

Ideas, suggestions, and/or review from delphij and jilles.
Pointy hats are completely my responsibility however.


# 230374 20-Jan-2012 dougb

If we're booting there is no need to waste time determining if the service
is running or not.

PR: conf/150752
Submitted by: YIN Xiaofeng <75394094@qq.com>


# 230103 14-Jan-2012 dougb

Now that its callers have been udpated, remove set_rcvar().

The concept of set_rcvar() was nice in theory, but the forks
it creates are a drag on the startup process, which is especially
noticeable on slower systems, such as embedded ones.


# 230007 12-Jan-2012 rea

rc.d: document 'quiet' prefix and fix dhclient/devd interaction

Document the current semantics of the 'quiet' command prefix
in the rc.subr(8).

Fix dhclient rc.d script: it should not call err() for
non-DHCP-enabled interface when it is called from devd, because the
latter just blindly calls 'service dhclient quietstart' on each "link
up" event.

Since the 'quietstart' will silence the message "Cannot 'start' <foo>.
Set <foo>_enable to YES in /etc/rc.conf or use 'onestart' instead of
'start'." and running dhclient on the non-DHCP-enabled interface is
the same thing as running the service <foo> without <foo>_enable set,
such modification is in sync with the current semantics of the 'quiet'
prefix.

Approved by: glebius
Reviewed by: freebsd-rc list
MFC after: 2 weeks


# 229822 08-Jan-2012 dougb

There is no longer a need to abstract ${rcvar_manpage} as we are not
attempting to maintain compatibility with NetBSD for some years now.


# 229783 07-Jan-2012 uqs

Spelling fixes for etc/


# 227366 08-Nov-2011 jilles

rc.d: Eliminate some unnecessary non-POSIX constructs:

* set - ...
* empty braces
* ^ in character class


# 223298 19-Jun-2011 jilles

rc.subr: Make sure all functions are under if [ -z "${_rc_subr_loaded}" ].


# 223292 19-Jun-2011 jilles

rc.subr: Eliminate a fork from check_kern_features, like r223227.

MFC after: 2 weeks


# 223227 18-Jun-2011 jilles

rc.subr: Eliminate about 100 forks from the boot sequence.

With the current sh, placing eval in a command substitution always results
in a fork(), even if it is the only command and only executes a single
simple command. Therefore, avoid it where it can be avoided easily.

Side effect: values starting with a hyphen and all whitespace are preserved.
The values are defaults and names for rc.conf variables and messages to be
given about obsolete ones.

MFC after: 2 weeks


# 222996 11-Jun-2011 hrs

Add a helper function to check kern.features.* sysctls.

Discussed with: dougb


# 220974 23-Apr-2011 dougb

As previously advertised, remove the error message for enable_quotas
prior to 9.0-RELEASE.

This change should not be MFC'ed.


# 220963 23-Apr-2011 dougb

Improve the error handling for the new get_pidfile_from_conf()


# 220962 23-Apr-2011 dougb

Introduce to rc.subr get_pidfile_from_conf(). It does just what it sounds
like, determines the path to a pid file as it is specified in a conf file.

Use the new feature for rc.d/named and rc.d/devd, the 2 services in the
base that list their pid files in their conf files.

Remove the now-obsolete named_pidfile, and warn users if they have it set.


# 220760 17-Apr-2011 dougb

The change in r206686 to allow the stop argument to work for a service
that is running even though not _enable'd had an annoying side effect.
If the service was already started at boot time by another means when
the related script came around again in rcorder it would start again,
regardless of _enable, because there was a valid pid. [1]

So, split the test into 2 parts, one for (!rcvar && !stop), and one
for (stop && !valid_pid). This preserves the behavior from r206686
while preventing the undesired side effect.

PR: conf/156427 [1]
Submitted by: Eugene Grosbein <eugen@grosbein.pp.ru> [1]


# 219612 13-Mar-2011 dougb

Revert r219578


# 219578 12-Mar-2011 dougb

Use the allexport option in load_rc_config() in order to avoid having
to repeatedly read the conf files. Depending on what is enabled the
files are being read anywhere from 15, 30, or more times currently.
By loading the values in the environment this is reduced to 1, with
perhaps a couple more, again depending on what is enabled.

The speed-up for boot and shutdown is negligible when rc.conf is
on local disk, noticable when accessing files over NFS, and dramatic
when pulling rc.conf values from a database.

This change also includes a minor optimization to the conditional
for $_rc_conf_loaded.


# 217090 07-Jan-2011 jh

Warn if rules could not be read from a ruleset file. Now at least
something gets logged if the file has syntax errors.

PR: conf/91342
Silence on: freebsd-rc


# 211319 14-Aug-2010 dougb

Fix silly typo on my part (s/quotas_enable/quota_enable/)

Submitted by: ed


# 211311 14-Aug-2010 dougb

Give people some warning before removing enable_quotas


# 206686 15-Apr-2010 dougb

If a service is running, make 'stop' work even if ${name}_enable
is not set.

PR: conf/130414
Submitted by: Dominic Fandrey <kamikaze@bsdforen.de>
Reviewed by: freebsd-rc@


# 206248 06-Apr-2010 dougb

In wait_for_pids(), pwait(1) can return when the process exits, but
still exists as a zombie. The 'kill -0' test in this function can
therefore return true even if the process isn't actually running.
This could lead to wait_for_pids() printing an endless string of the
pid number until the zombie finally exits.

Solve this problem by moving the sleep up to after the 'kill -0' test, but
only after we've run through the function once already. In the common case
(only one pid in the list) this will always do the right thing. On the rare
occasion that there is more than one pid in the list this will sleep 1
second per zombie process which will allow that process, and any other
in the list a chance to exit.

While I'm here, local'ize the variables that this function uses.


# 203022 26-Jan-2010 emaste

Convert to 2-clause license, from NetBSD rc.subr r1.70.

Submitted by: Alex Kozlov
Obtained from: NetBSD


# 202988 25-Jan-2010 emaste

Remove vestigial NetBSD compatibility shim.


# 201038 27-Dec-2009 dougb

Update the comments about files ending in .sh

Prompted by: Alex Kozlov <spam@rm-rf.kiev.ua>


# 201036 27-Dec-2009 dougb

Delete some trailing whitespace


# 200818 21-Dec-2009 jilles

rc.subr: Use pwait in wait_for_pids.

This waits for the requested process(es) to terminate, rather than polling
with an interval of 2 seconds.

If pwait is not available, the old method is used.

PR: conf/132766
Reviewed by: dougb


# 198216 18-Oct-2009 ed

Fix qouting in a comment, to make it look more consistent

Submitted by: Jille Timmermans <jille quis cx>
MFC after: 1 week


# 198162 15-Oct-2009 dougb

Allow $name_program to override $command in a more robust way that
will not cause the value to be null if $command is not set.


# 197947 10-Oct-2009 dougb

In regards to the "Starting foo:" type messages at boot time, create and
employ a more generic solution, and use it in the individual rc.d scripts
that also have an $rc_quiet test:

1. Add check_startmsgs() to rc.subr.
2. In the rc.d scripts that use rc_quiet (and rc.subr) substitute
variations of [ -z "$rc_quiet" ] with check_startmsgs
3. In savecore add a trailing '.' to the end of the message to make it
more consistent with other scripts.
4. In newsyslog remove a : before the terminal '.' since we do not expect
there to be anything printed out in between to make it more consistent.
5. In the following scripts change "quotes" to 'quotes' where no variables
exist in the message: savecore pf newsyslog
6. In the following scripts substitute if/then/fi for the simpler (and
more consistent) check_startmsgs &&: faith stf
7. In the following scripts separate the "Starting foo:" from the terminal
'.' to make them more consistent: moused hostname pf
8. In nfsclient move the message to its own line to avoid a style bug
9. In pf rc_quiet does not apply to the _stop method, so remove the
test there.
10. In motd add 'quotes' around the terminal '.' for consistency


# 197790 05-Oct-2009 hrs

Fix a case when both ${name}_program and ${command} are defined.

Spotted by: Michio "Karl" Jinbo


# 197297 17-Sep-2009 dougb

Add a knob to show 'Starting foo:' messages when faststart is used,
such as at boot time.


# 197144 12-Sep-2009 hrs

Add an extension of set_rcvar(), a new function set_rcvar_obsolete(),
and $desc.

The set_rcvar_obsolete() is for displaying an obsolete variable
and the new one. More specifically, a warning is displayed when
a variable is removed or changed in the source tree and the user
still defines the old one.

$router* and $ipv6_router* are replaced with $routed_* and
$route6d_* for consistency. The old variables still work but
can be removed in the future.

MFC after: 3 days


# 193118 30-May-2009 dougb

Now that the last of the *.sh scripts are gone from the base,
emit a warning if come across one.


# 184317 26-Oct-2008 thompsa

Show which rc script is running since the default ^T just shows 'sh' as the
process.


# 179946 23-Jun-2008 mtm

Move the diagnostic output when the rc.subr(8) glue automatically starts a
service behind $rc_quiet. Instead, output a warning if the pre-command
routine or the command itself failed. Arguably, it's more useful to know when
a command failed to start than it is to have an endless list of
"Starting ...." lines[1].

[1] - This change actually helped me to discover a bug in rc.d/{lockd,statd}
(fixed in r179941) that used to fail silently before.


# 179872 19-Jun-2008 mtm

Make quota knob conform to other rc(8) knobs. Keep older knob for
compatibility.

Requested by: Volker <volker@vwsoft.com>


# 179870 19-Jun-2008 mtm

Move the check for enabled knobs further down in run_rc_command() so
that bogus commands cause usage information to be printed instead of
diagnostics about enabling the knob.


# 178776 05-May-2008 maxim

o Convert whitespaces to tabs.


# 178775 05-May-2008 maxim

o Terminate "case" with "esac" not "fi".

Reported by: Randy Bush


# 178770 05-May-2008 mtm

Fix improper use of checkyesno routine.

Noticed by: oliver
MFC after: 1 week


# 175676 26-Jan-2008 mtm

Re-implement: do not silently fail when a command is not carried
out because the rc.conf(5) variable was not enabled. Display a
message that the command wasn't run and offer suggestions on
what the user can do.

Implement a quiet prefix, which will disable some diagnostics. The
fast prefix also implies quiet. During boot we use either fast or
quiet. For shutdown we already use 'faststop'. So, this informational
message should only appear during interactive use.

An additional benefit of having a quiet prefix is that we can start
putting some of our diagnostic messages behind this knob and start
"de-cluttering" the console during boot and shutdown.


# 175662 25-Jan-2008 mtm

Backout previous commit. It's going to clutter the console
during boot and shutdown. I think I'll hide it behind autoboot or
maybe take brooks@ suggestion and implement a different command
prefix for booting/shutdown purposes, but in any case it needs more
thought and attention.

Noticed by: ceri
Pointyhat to: mtm


# 175660 25-Jan-2008 mtm

If the rc.conf(5) variable for a script is not enabled do not fail
silently. Display a message that the command wasn't run and make
possible suggestions for what to do.

PR: conf/118770
MFC after: 1 week


# 172487 09-Oct-2007 dougb

Remove pre-rc.d compatibility shims that were added before the 5.0 branch
for pre-5.0 variable names.

Remove two dhcp compatibility variables added after the 5.1-RELEASE.

Remove the now-unused support for these shims.

Approved by: re (kensmith)


# 170282 04-Jun-2007 yar

Be robust to a bogus script specification or contents
when figuring out what the real interpreter is for an
interpreted command. That is, check whether we can read
the script file in the first place and, if so, make sure
we got a valid shebang line from it.


# 169668 18-May-2007 mtm

o Implement the stop_boot subroutine [1]. This subroutine can be used by
scripts in rc.d to stop rc(8) from booting into multi-user mode when
a critical or severe error condition is encountered.

o Modify scripts in etc/rc.d that already implemented this functionality
independently.

o Document it.

[1] - This subroutine was implemented in FreeBSD in rc.d/fsck. I moved it
to rc.subr(8). Our version differs slightly in that it takes an
optional argument to stop the boot even if "autoboot" is not set.

Obtained from: NetBSD
MFC after: 2 weeks


# 167413 10-Mar-2007 yar

Prepend ${_chroot} to a pathname in a consistent and robust way:
insert a slash between ${_chroot} and the pathname if and only if
${_chroot} is set to a non-empty string. Now the pathname is very
likely to be absolute, but we shouldn't take that for granted.


# 165684 31-Dec-2006 yar

Allow for /usr/bin/env when parsing the shebang line from an
interpreted $command. Some "portable" sofware packages use such a
line to skip the task of figuring out the absolute pathname of the
interpreter at install time, e.g.:

#!/usr/bin/env python

It is insecure, but a popular book on Python seems to have advised
it to a wide audience. Hence a number of such scripts in the ports,
mostly written in Python.

PR: bin/100287
MFC after: 1 week


# 165565 27-Dec-2006 yar

MFp4:

Implement the checks for required_* objects as two functions, one
to be run before precmd and the other after it. They get the current
rc command as an argument so they can choose what requirement tests
to perform. As of now, only "start" needs such tests.

Implement a new requirement variable, required_modules. It can
list kernel modules that need to be loaded after start_precmd
indicated success. Each name in the list can be just "file", or
"file:module", or "file~regex". This will allow us to remove a lot
of duplicated code from rc.d scripts.

Perform the checks not only for the default start method, but for
any method. This allows for more flexibility and fixes a few rc.d
scripts (namely newsyslog, pf, sendmail) that rely on a required_*
variable while providing a non-default start method.

To be able to call the new check_required* functions naturally,
remove lots of crufty duplicated code pieces from run_rc_command
and replace each of them by a call to the helper function providing
a single corrected instance of the respective code snippet. Now
run_rc_command isn't as scary as it used to be, and it even appears
to have quite a nice logic that was obscured by the old crufty code.

In the default handler for restart, run start from a subshell to
protect global varibles, e.g., _postcmd, from modification by the
start handler. This enables using restart_postcmd. [x]

PR: conf/98734 [x]
Submitted by: Rick van der Zwet <rick@wzoeterwoude.net> [x]
Reviewed by: freebsd-rc (silence for an older version)
MFC after: 1 month


# 164640 26-Nov-2006 flz

Teach find_processes() to use ${name}_chroot.

Obtained from: NetBSD
X-MFC after: 6.2-RELEASE


# 164629 26-Nov-2006 flz

Remove leading dollar sign in rcvar command output.
There's no dollar use in variable assignment in sh.
Assuming this is can be expected behavior for some
people, this change won't be MFC'ed to RELENG_6.

Discussed with: yar on -rc


# 162947 02-Oct-2006 yar

debug() shouldn't misidentify itself to logger(1).

Noticed by: David Thompson <dat1965 yahoo com>


# 161530 22-Aug-2006 flz

Backout this commit since it breaks startup and some scripts in
certain conditions. I haven't been able to find a better solution yet:

- Set a two read-only variables (${prefix} and ${etcdir}). This is
especially useful when using /etc/rc.d scripts with third-party
software installed from ports.
- Fix rc.d/sshd to work with openssh from ports using ${etcdir}
instead of hardcoded /etc.
- Reflect prefix/etcdir changes in rc.subr.8.

src/etc/rc.d/sshd: rev 1.9 -> 1.10
src/etc/rc.subr: rev 1.51 -> 1.52
src/share/man/man8/rc.subr.8: rev 1.11 -> 1.12

Approved by: cperciva (mentor)


# 161436 18-Aug-2006 yar

Eliminate header line(s) from ps(1) output instead of skipping over them.


# 161435 18-Aug-2006 yar

The ps(1) command is unfriendly to scripts by default because
it limits the width of its output to the value of $COLUMNS, or
what TIOCGWINSZ reports, or 79 columns. We should specify -ww
to ps(1) so that it removes the limit and prints lines in full.
Otherwise very long command pathnames could be mishandled, e.g.,
by _find_processes().

MFC after: 1 week


# 161396 17-Aug-2006 yar

Allow for setting negative priority (niceness) when $foo_user is non-root.
The order in _doit must be "nice su", not "su nice", for that.
In addition, don't ignore the exit status from "cd $foo_chdir".

Reviewed by: freebsd-rc (silence)
MFC after: 1 week


# 160698 26-Jul-2006 yar

Back out rev. 1.63. It was a poor idea because
test(1) is built in sh(1) and it always evaluates
both sides of -a or -o, unlike && or || in sh(1).

Requested by: dougb


# 160670 25-Jul-2006 yar

Avoid extra runs of test(1) by using its built-in logical operations.


# 160668 25-Jul-2006 yar

Sync comments around _doit with the code.


# 160667 25-Jul-2006 yar

We notify of failures with err or warn.
Messages should end in full stop unless
that can lead to confusion.


# 160666 25-Jul-2006 yar

Add diagnostics to load_kld().


# 159828 21-Jun-2006 yar

Quite a number of rc.d scripts try to load kernel modules. Many
of them do that conditionally depending on kldstat. The code is
duplicated all over, but bugs can be uniqie.

To make the things more consistent, introduce a new rc.subr function,
load_kld, which takes care of loading a kernel module conditionally.

(Found this lying for a while in my p4 branch for various hacks.)


# 158723 18-May-2006 flz

Remove the require_kld function I just committed and replace with a nicer solution.

Reported by: pjd
Approved by: cperciva


# 158722 18-May-2006 flz

Add two new scripts (mdconfig/mdconfig2) to replace old ramdisk{,-own}
scripts. These scripts handle vnode backed md(4) devices.

Old ramdisk{,-own} scripts will stay a bit in CVS to allow some time for
migration since variable names have changed (ramdisk_* -> mdconfig_*).

Two new variables have been introduced to be able to populate the md(4)
device once it has been mounted (mdconfig_*_files and mdconfig_*_cmd).

Use should be as easy as:

mdconfig_md0="-t malloc -s 10m"
mdconfig_md1="-t vnode -f /var/foo.img"

See rc.conf(5) for more information and description of the additional
variables.

Approved by: cperciva


# 157841 18-Apr-2006 flz

- Move _rc_subr_loaded=: at the end of the file, to be consistent with NetBSD.
- Sync with latest version from NetBSD.

'In order to handle some perl scripts running as daemons, add a
pattern which also matches "`basename $interpreter`: $command" in the
ps listing.'

Approved by: cperciva (mentor)
Obtained from: NetBSD
MFC after: 1 week


# 157710 13-Apr-2006 flz

Use ps true power instead of tr/tail which aren't available early enough.

PR: conf/95654
Submitted by: Rong-En Fan <rafan@infor.org>
Noticed/Fix by: many people on freebsd-current@
Approved by: cperciva (mentor)


# 157657 11-Apr-2006 flz

- If no pidfile has been created at startup, only stop processes
with current jid.

PR: conf/93287
Submitted by: anders
Approved by: cperciva (mentor)
MFC after: 1 month


# 157656 11-Apr-2006 flz

- Oops, add a missing "then".

Approved by: cperciva (mentor, implicit)


# 157653 11-Apr-2006 flz

- Set a two read-only variables (${prefix} and ${etcdir}). This is
especially useful when using /etc/rc.d scripts with third-party
software installed from ports.
- Fix rc.d/sshd to work with openssh from ports using ${etcdir}
instead of hardcoded /etc.

Reviewed by: brooks
Approved by: cperciva (mentor)
MFC after: 1 week


# 157473 04-Apr-2006 flz

- Sync rc.subr with NetBSD.
- Merge some documentation bits.

Reviewed by: brooks, simon (doc)
Approved by: cperciva (mentor)
Obtained from: NetBSD
MFC after: 3 days


# 157048 23-Mar-2006 flz

Harmless typo (s/overide/override/).

Approved by: cperciva
MFC after: 3 days


# 155719 15-Feb-2006 ceri

Update a comment to match functionality changed in r1.39 (allow square
brackets in process names).

MFC after: 2 days


# 155570 12-Feb-2006 flz

Don't include geli devices in list when noauto is specified in the options field.

Approved by: pjd
MFC after: 3 days


# 153297 10-Dec-2005 dougb

Silence a warning about empty directories in all the places it might
occur.

Reminded by: yar


# 153152 06-Dec-2005 yar

Since rc.subr is a library of functions, it should not use exit
every now and then. It is up to the caller to choose a proper
action upon an error condition. Therefore, use return, not exit,
except for some special cases.

Consistently return 1 to indicate an error.

Submitted by: sem (initially)
Reviewed by: freebsd-rc (silence)
MFC after: 2 weeks


# 153105 05-Dec-2005 dougb

Change how *.sh scripts are handled. If the script is in /etc/rc.d,
source it into the shell. If not, handle it in a subshell the same
way that "real" rc.d-style scripts are handled. This will dramatically
ease the "process local scripts in the base rcorder" transition.

Add *.bak to the list of files in */rc.d that we ignore.


# 153027 02-Dec-2005 dougb

Introduce startup scripts from the local_startup directories to
the base rcorder. This is accomplished by running rcorder twice,
first to get all the disks mounted (through mountcritremote),
then again to include the local_startup directories.

This dramatically changes the behavior of rc.d/localpkg, as
all "local" scripts that have the new rc.d semantics are now
run in the base rcorder, so only scripts that have not been
converted yet will run in rc.d/localpkg.

Make a similar change in rc.shutdown, and add some functions in
rc.subr to support these changes.

Bump __FreeBSD_version to reflect this change.


# 152519 16-Nov-2005 yar

Avoid invoking the current script again when we need
to issue sub-commands, e.g., restart = stop + start.
By calling run_rc_command instead, we provide rc.d
scripts with full control over their configuration
variables.

For an example problem the former approach caused, see
http://lists.freebsd.org/pipermail/freebsd-rc/2005-October/000311.html

Reviewed by: freebsd-rc
Tested by: Dirk Engling erdgeist <at> erdgeist.org
MFC after: 2 weeks


# 151687 26-Oct-2005 yar

Override $command with $foo_program only if $command
has been set in the first place. This should reduce
unwanted side-effects in rc.d scripts that don't mean
to use $command and rc.subr(8) methods associated with
it at all.

Discussed with: brooks
Reviewed by: -rc (silence)


# 151685 26-Oct-2005 yar

Document that `reload' is not provided by default
yet it can be enabled when applicable.


# 151619 24-Oct-2005 maxim

o Grammar.

Submitted by: Ulrich Spoerlein
MFC after: 1 week


# 151426 17-Oct-2005 jhb

Allow the process name to be in square brackets ([]) in _find_processes().

PR: conf/82430
Submitted by: Pavel Volkov pol at iib dot ru
MFC after: 1 week


# 150796 01-Oct-2005 yar

Fix the usage of rc_usage. The rc_usage function takes
a list of possible keywords, not all them in a single argument.
This also fixes the issue of extra delimiter characters appearing
on the help line from rc.d scripts not setting $extra_commands.


# 149421 24-Aug-2005 yar

Stop hard-coding an -M flag to mdmfs(8) in /etc/rc.subr.
Now this flag can be set, or not set, for memory-backed
file systems on individual basis, as illustrated by the
rc.conf(5) variables tmpmfs_flags and varmfs_flags. The
flag is set for those FS'en by default, in /etc/defaults/rc.conf,
in order to stay compatible with the old rc.subr behaviour.

Submitted by: marck
MFC after: 3 days


# 149050 14-Aug-2005 pjd

Add scripts for GELI device configuration on boot.

rc.d/geli - configures encryption (ask for passphrases, etc.);
rc.d/geli2 - is called after file systems are mounted and mark devices for
detach on last close.

Sponsored by: Wheel Sp. z o.o.
http://www.wheel.pl
MFC after: 3 days


# 149049 14-Aug-2005 pjd

Move 'local_tr' function to rc.subr and change its name to 'ltr'.

MFC after: 3 days


# 146490 22-May-2005 schweikh

Style: mostly tabs vs blanks, and semicolon placement.


# 139949 09-Jan-2005 keramida

Cosmetic typo in check_pidfile()

PR: bin/75946
Submitted by: zero@gddn.org (Finn)


# 137451 09-Nov-2004 keramida

Add two new rc.conf options: tmpmfs_flags and varmfs_flags.

These can be used to pass extra options to the mdmfs(8) utility,
to customize the finer details of the md file system creation
(i.e. to turn on/off softupdates, to specify a default owner for md
filesystem, etc).

Use these two new flags to mount tmpmfs and varmfs without
softupdates, since it doesn't make much sense to use SU on
malloc-backed file systems.

Reviewed by: mtm
Inspired by: J. D. Bronson, jbronson at wixb dot com


# 132892 30-Jul-2004 mtm

Finish cleanup of rc.d/netif. It's now possible to start/stop more
than one interface from the command line:
# /etc/rc.d/netif start bfe0 xl0
It's also possible to restart an interface(s):
# /etc/rc.d/netif restart bfe0

This required some changes to rc.subr(8) so that if the start/stop commands
are overidden the rest of the command line (after the start/stop/etc... cmd)
is passed through to the subroutines.


# 131550 04-Jul-2004 cperciva

Wrap rc.subr inside

if [ -z "${_rc_subr_loaded}" ]; then
_rc_subr_loaded="YES"
...
fi

in order to avoid re-interpreting rc.subr every time an rc.d
script is run. In my tests, this speeds up rc time by about
8-10%.


# 131135 26-Jun-2004 mtm

Make the stop command respect the 'fast' prefix.

Most notably, this cleans up messages when shutting down from
single user. In such a case there are usually no daemons running,
but their pid files are still in /var/run. This causes rc.d to
output diagnostics about daemons with pidfiles, but that are
not running.


# 131061 24-Jun-2004 mtm

Fix typo.

Submitted by: kuriyama


# 130161 06-Jun-2004 mtm

Restore pre-rcNG behaviour:
SIGINT (Ctrl-c) kills the current script
SIGQUIT (Ctrl-\) kills /etc/rc (dropping you into single-user)

Prodded by: harti


# 127345 23-Mar-2004 brooks

Overhaul the /etc/rc.d/diskless script by splitting it out into
hostname, resolve, tmp, and var scripts. The latter three are new and
were repo copied. These scripts no longer depend on being booted with
and NFS root instead attempt to automaticly create mfs /tmp and /var
volumes if the they are not writable. This behavior can be overridden
in /etc/rc.conf.

Reviewed by: luigi, pjd


# 126556 03-Mar-2004 mtm

Some (most?) processes don't cleanup their pid files when
they exit. Sometimes they simply can't (core-dump, for example).
So, when searching for a running program send standard error
output from ps(1) to never-never land.

# This should quite those
# ps: kvm_getprocs: No such user
# errors. Since ports use a duplicate rc.subr(8) you might
# still see this error from ports startup scripts.


# 126303 27-Feb-2004 mtm

NetBSD rev. 1.61
Implement ``one'' prefix to allow a "one shot" operation as if
${rcvar}=yes yet all the other prerequisite tests are still performed.
The existing ``force'' prefix is a sledgehammer that ignores all the
prerequisite checks and always returns a zero exit status; this is a
more gentle approach to the problem of "manipulate this disabled
service without editing rc.conf(5)".

Obtained From: NetBSD

# We have a work-around in our version of rc.subr that
# makes force* return a non-zero exit status if the
# command/service could not be acted upon. The work-around
# is no longer necessary and should be removed.


# 126288 26-Feb-2004 mtm

o NetBSD rev. 1.60
Add "*,v" to the list of scratch files to skip.
Suggested by Johnny Lam / Alistair Crooks

o Update NetBSD rcsid

Obtained From: NetBSD


# 126287 26-Feb-2004 mtm

NetBSD rev. 1.57
run_rc_command(): when checking if ${command} exists before executing it,
be sure to check under ${name_chroot} (if set).
Fix from Ed Ravin in [bin/18523]

Obtained From: NetBSD


# 126286 26-Feb-2004 mtm

NetBSD rev. 1.56
Use more concise shell syntax:
1. for i in $* -> for i
2. foo=$* -> foo="$@"

Obtained From: NetBSD


# 126285 26-Feb-2004 mtm

NetBSD rev. 1.53, 1.54 and 1.55:
Change how internal boolean variables are used to:
if ! ${_somevar:-false}; then
_somevar=true
fi
(Consisent, slightly quicker, and slightly cleaner)

Obtained from: NetBSD


# 124832 22-Jan-2004 mtm

Since id(1) is in /usr, it may not be available until after filesystem
mounting.

Reminded by: bde


# 124797 21-Jan-2004 cperciva

After setting a ruleset on a new devfs mount, apply it.

Approved by: phk, rwatson (mentor)
PR: bin/61047


# 123344 09-Dec-2003 mtm

o Rename devfs_link() to make_symlink() and turn it into a generic
symlinking routine.
o Modify rc.d/jail to create its own symlink relative to the jail's
filesystem


# 119170 20-Aug-2003 mtm

o Reduce rc(8) startup clutter by turning the informational messages
off by default.
o Apparently the routine displaying the informational messages wasn't
checking its knob in rc.conf, so fix that as well.

Requested by: obrien


# 119166 20-Aug-2003 mtm

Add a general mechanism for creating and applying
devfs(8) rules in rc(8). It is most useful for applying
rules to devfs(5) mount points in /dev or inside jails.
The following line of script is sufficient to
mount a relatively useful+secure devfs(5) in a jail:

devfs_mount_jail /some/jail/dev

Some new shell routines available to scripts that source
rc.subr(5):
o devfs_link - Makes it a little easier to create symlinks
o devfs_init_rulesets - Create devfs(8) rulesets from devfs.rules
o devfs_set_ruleset - Set a ruleset to a devfs(5) mount
o devfs_apply_ruleset - Apply a ruleset to a devfs(5) mount
o devfs_domount - Mount devfs(5) and apply some ruleset
o devfs_mount_jail - Mount devfs(5) and apply a ruleset
appropriate to jails.

Additional rulesets can be specified in /etc/devfs.rules.
If the devfs_system_ruleset variable is defined in rc.conf
and it contains the name of a ruleset defined in /etc/defaults/devfs.rules
or user supplied rulesets in /etc/devfs.rules then that ruleset will
be applied to /dev at startup by the /etc/rc.d/devfs script. It can
also be applied post-startup:

/etc/rc.d/devfs start

This is a more flexible mechanism than the previous method of using
/etc/devfs.conf. However, that method is still available.

Note: since devfs(8) doesn't provide any way for creating symlinks
as part of a ruleset, anyone wishing to create symlinks in a devfs(5)
as part of the bootup sequence will still have to rely on /etc/devfs.conf.


# 117977 24-Jul-2003 mtm

Missing quotes around a variable. In this case we are only
evaluating the $_precmd command as a string. We're not actually
trying to evaluate the contents of the command.

Reported by: Glenn Johnson <gjohnson@srrc.ars.usda.gov>


# 116097 09-Jun-2003 mtm

Previously, a "forced" command always exited successfully (with the
exception of the default 'status' command) regardless of whether the
executed command was actually successfull or not. Forced scripts should
always correctly reflect the outcome of the command.

NOTE: exit values are treated as booleans. We don't care what
the actual exit value was, only whether it was successfull or not.


# 115950 07-Jun-2003 mtm

The dhcp_program and dhcp_flags variables have to be renamed to
take advantage of the rc.subr(8) glue. They are renamed dhclient_program
and dhclient_flags.
o Rename them in rc.conf(5)
o Rename them in /etc/defaults/rc.conf
o Add the deprecated variables to /etc/rc.subr
o Isolate the use of the 'command' variable to the
NetBSD specific parts in /etc/rc.d/dhclient.
o Now that dhcp_flags has also been renamed it will
be applied properly by rc.subr(8) glue code.

Reported by: John Nielsen <john@jnielsen.net>


# 114272 30-Apr-2003 mtm

This particular debugging statement is very verbose, making the rest
of the debug output hard to follow. Comment it out. It's commented out
in NetBSD's version as well.

Approved by: markm (mentor)(implicit)


# 109582 20-Jan-2003 mtm

Write out the debug messages (from the previous commit) only if
the evaluated command exists.

Approved by: markm (mentor)(implicit)


# 109465 18-Jan-2003 mtm

Make the debug messages, for when a script rolls its own start routine,
more usefull. Currently it just says 'xxx_cmd'; whereas with this
change it will name the routine that's being run.

Approved by: markm (mentor)


# 106700 09-Nov-2002 gordon

By popular demand, make the debug log to syslog.
Remove an extraneous return too.


# 106643 08-Nov-2002 gordon

Diff reduction to NetBSD:

Fix a minor grammer nit.
Get rid of _echo that uses logger and just call logger in the 3 routines
that need it.
Add a comment referencing rc.conf(5) in the case of an incorrectly set
variable.

This pulls rc.subr up to 1.51 of rc.subr. I skipped 1.49 (systrace support)
since I don't have systrace.

Obtained from: NetBSD


# 103262 12-Sep-2002 gordon

Remove the sourceing of rc.conf from the debug subroutine. This caused
problems when you try to override variables locally.


# 103018 06-Sep-2002 gordon

Add a support for a ${OSTYPE} which is set once in /etc/rc.subr. Also convert
all instances of `${CMD_OSTYPE}` to just using ${OSTYPE}. This saves us a
shell invocation on anything that is OS-dependent. I seriously doubt that we
will be spontaneously changing OS types during bootup.


# 101850 14-Aug-2002 gordon

Clean up some variables that should have been done before:
xntpd_* -> ntpd_*
portmap_* -> rpcbind_*

Also change single_mountd_enable to mountd_enable.

We also include shims for all the old variable names.

Submitted by: Mike Makonnen <makonnen@pacbell.net>


# 98186 13-Jun-2002 gordon

Bring this up to date with the latest NetBSD bits. Also add some bits of
our own.

Submitted by: Mike Makonnen
Reviewed by: silence on -current and -hackers


# 95258 22-Apr-2002 des

Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.


# 78345 16-Jun-2001 obrien

This commit was generated by cvs2svn to compensate for changes in r78344,
which included commits to RCS files with non-trunk default branches.


# 78344 16-Jun-2001 obrien

Import the NetBSD 1.5 RC system.

Note that `rc' and `rc.shutdown' could not be imported because we already
have files with those names.