History log of /freebsd-current/share/man/man8/rc.subr.8
Revision Date Author Comments
# 11333dd5 24-May-2024 Franco Fichtner <franco@opnsense.org>

rc: improve NAME_setup handling

Reload is used for service reconfiguration as well
and lacks a NAME_prepend-like mechanism so it makes
sense to extend the NAME_reload hook into this
action.

precmd may use configuration checks and blocks setup
from doing its designated work (e.g. nginx). In moving
the invoke of the setup script in front allows us to
provide custom scripts for config file generation and
fixing prior to precmd checking configuration integrity.

Also introduce _run_rc_setup to separate the launcher
from the main one. Let it run correctly in the case
of restart_precmd and block further execution as
would be the case in start due to the internal plumbing
of restart being split into calling stop and start
afterwards.

Differential-Revsiion: https://reviews.freebsd.org/D36259
Signed-off-by: Franco Fichtner <franco@opnsense.org>
Reviewed by: imp, oshogbo
Pull Request: https://github.com/freebsd/freebsd-src/pull/1258


# 41f9823e 10-Feb-2024 Simon J. Gerraty <sjg@FreeBSD.org>

rc.subr.8 note when DebugOn will be called


# aa3b7a2f 09-Feb-2024 Simon J. Gerraty <sjg@FreeBSD.org>

/etc/rc add trace debug and verify

Debugging boot issues can be helped by
logging each rc.d script as it is run
and being able to selectively enable/disable set -x
debug.sh provides an elaborate framework for debugging shell scripts.

For secure systems, we want to be paranoid about what we read
during boot.

dot() simply reads (.) arg file if it exists
vdot() if mac_veriexec is active, ignore unverified files
otherwise behaves much the same as dot()
safe_dot() in safe_eval.sh allows reading an untrusted file;
limiting the input to simple variable assignments.

In load_rc_config allow caller to provide an option to indicate how to
handle its arg:
-v use vdot()
-s use sdot() which will try to use vdot() and fallback to safe_dot()
The default is to read using dot()

rc_run_scripts()
encapsulate the running of rc.d scripts
so that we can easily call it more than twice.

We vdot local.rc.subr to pick up extensions (like
run_rc_scripts_final) and overrides.

We also allow rc.subr.local or rc.conf to set rc_config_xtra
eg (rc_config_xtra=XXX for historic compatibility)

rc use set -o verify around the reading in of rc.subr
This has no effect if mac_veriexec is not active, but if it is; ensures
rc.subr has not been tampered with.

Reviewed by: imp
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43671


# fa9896e0 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line nroff pattern

Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/


# b05e7e70 11-Nov-2022 Franco Fichtner <franco@opnsense.org>

rc: add a manual entry for ${name}_setup

${name}_prepend is suboptimal as it is prepended to the actual
command being run. Therefore the term "commandS to prepend"
is misleading and no clear separation takes place for setup tasks
that may be required like changing a config file permission or
generating a configuration file prior to service start.

The other reason is that {argument}_precmd is a service-side
variable and cannot be repurposed from the user-side.

Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D36210


# fa1dab78 18-Mar-2022 Mateusz Piotrowski <0mp@FreeBSD.org>

rc.subr.8: Format notes consistently

MFC after: 3 days


# 325ebf37 13-Mar-2022 Jose Luis Duran <jlduran@gmail.com>

Introduce startmsg and use it in rc scripts

startmsg is a new rc.subr(8) function function to be used instead of
echo(1) when for boot messages. It replaces the often forgotten

check_startmsgs && echo ...

with

startmsg ...

No functional change intended.

I adjusted the commit message and did some final clean-ups of the patch
before committing.

PR: 255207
Reported by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp, 0mp
Approved by: imp (src)
Differential Revision: https://reviews.freebsd.org/D34514


# 5d21348d 29-Nov-2021 Mateusz Piotrowski <0mp@FreeBSD.org>

rc.subr.8: Document changes to load_rc_config

Since e27961a496322e2590da29f3c5fe710b269e6754, load_rc_config does not
require a service name as its first argument. This change was documented
in the rc.subr script in 0b9c2e7ac58caac0413aa36749e4c212514d142d. Let's
update the manual page as well.

MFC after: 3 days


# 0b87619f 31-Jul-2020 Mateusz Piotrowski <0mp@FreeBSD.org>

Point to rc(8) for more details about the autoboot variable

Reviewed by: bcr, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25904


# d6dade00 24-Jul-2020 Mateusz Piotrowski <0mp@FreeBSD.org>

Fix grammar issues and typos

Reported by: ian
MFC after: 1 week


# 5ccb7079 24-Jul-2020 Mateusz Piotrowski <0mp@FreeBSD.org>

Document that force_depend() supports only /etc/rc.d scripts

Currently, force_depend() from rc.subr(8) does not support depending on
scripts outside of /etc/rc.d (like /usr/local/etc/rc.d). The /etc/rc.d path
is hard-coded into force_depend().

MFC after: 1 week


# d15e810d 05-Sep-2019 Mateusz Piotrowski <0mp@FreeBSD.org>

rc: Honor ${name}_env when a custom *_cmd is defined (e.g., start_cmd)

A user may set ${name}_env variable in rc.conf(5) in order to set additional
environment variables for a service command. Unfortunately, at the moment
this variable is only honored when the command is specified via the command
variable. Those additional environment variables coming from ${name}_env
are never set if the service is started via the ${rc_arg}_cmd variable (for
example start_cmd).

PR: 239692
Reviewed by: bcr, jilles
Approved by: src (jilles)
Differential Revision: https://reviews.freebsd.org/D21228


# ac102a2a 05-Jan-2019 Kyle Evans <kevans@FreeBSD.org>

rc.subr: Provide rc_service variable for service scripts

Some rc scripts in ports (e.g. uwsgi, apache, openvpn) allow for
'application profiles' that usually require the rc script to be invoked
again for each active profile. Because there's no consistent way to
determine the path because it differs between manual/service(8) invocations
and /etc/rc invocations, this leads to patterns like these:

- www/uwsgi hardcodes the script path
- security/openvpn guesses either $_file or $0 based on $0 = /etc/rc

Instead of forcing rc scripts to guess, provide an rc_service variable to
the scripts that gets set appropriately both for direct execution or when a
script is being executed via run_rc_script (e.g. /etc/rc).

This is our analog of an OpenRC variable with the same name, different case
(RC_SERVICE).

PR: 234614
Reported by: koobs
Reviewed by: dteske, jilles
MFC after: 3 days


# fda4dad5 07-Nov-2018 Mateusz Piotrowski <0mp@FreeBSD.org>

rc.subr(8): Document when required_* variables are processed

At the moment rc.subr(8) supports the following required_* variables:
required_dirs, required_files, required_modules and required_vars.

This patch documents when every of those required_* variables is actually
processed (before or after running start_precmd).

Reviewed by: bcr
Approved by: krion (mentor, implicit), mat (mentor, implicit)
Sponsored by: Bally Wulff Games & Entertainment GmbH
Differential Revision: https://reviews.freebsd.org/D17895


# 293f5f02 06-Aug-2018 Mateusz Piotrowski <0mp@FreeBSD.org>

Fix "mandoc -Tlint" warnings.

Reviewed by: bcr
Approved by: mat (mentor)
Differential Revision: https://reviews.freebsd.org/D15580


# 6b82569f 19-Jun-2018 Mark Felder <feld@FreeBSD.org>

Document the new ${name}_env_file feature

Approved by: bcr
MFH: 3 days
Differential Revision: https://reviews.freebsd.org/D15578


# 3c3b8a0e 03-Apr-2018 Jilles Tjoelker <jilles@FreeBSD.org>

rc.subr.8: Improve documentation of ${name}_limits and ${name}_login_class

Submitted by: 0mp
Differential Revision: https://reviews.freebsd.org/D14928


# 52d7a78f 06-Feb-2018 Dmitry Marakasov <amdmi3@FreeBSD.org>

- Document new ${name}_limits rc.conf option

Approved by: cy
MFC after: 2 weeks (along with 328331 which introduced this option)
Differential Revision: https://reviews.freebsd.org/D14028


# 5b71d899 17-Sep-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Remove backup_uses_rcs from rc.subr

In preparation for the removal of GNU rcs from base, remove the backup_uses_rcs
functionality from the rc.subr backup_file feature. This functionnality was off
by default

Reviewed by: wblock
Differential Revision: https://reviews.freebsd.org/D7883


# 3bead71e 23-Feb-2016 Marcelo Araujo <araujo@FreeBSD.org>

- Add a global option where we can protect processes when swap space
is exhausted.

How to use:

Basically we need to add on rc.conf an another option like:

If we want to protect only the main processes.
syslogd_oomprotect="YES"

If we want to protect all future children of the specified processes.
syslogd_oomprotect="ALL"

PR: 204741 (based on)
Submitted by: eugen@grosbein.net
Reviewed by: jhb, allanjude, rpokala and bapt
MFC after: 4 weeks
Relnotes: Yes
Sponsored by: gandi.net
Differential Revision: https://reviews.freebsd.org/D5176


# 61a8e849 11-Oct-2014 Hiroki Sato <hrs@FreeBSD.org>

Add ${name}_env and ${name}_prepend. ${name}_env is an argument list which
will be passed to env(1). ${name}_prepend is simply prepended to the command
line for $command.


# 49cede74 22-Sep-2013 Dag-Erling Smørgrav <des@FreeBSD.org>

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)


# c86072f5 14-Jan-2012 Doug Barton <dougb@FreeBSD.org>

Remove documentation for set_rcvar() now that it has been removed.


# 0113cca4 11-Jan-2012 Eygene Ryabinkin <rea@FreeBSD.org>

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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 57984250 27-Jan-2010 Ed Maste <emaste@FreeBSD.org>

Clean up rc.subr man page after removing leftover NetBSD compat. Also
switch to 2-clause license per NetBSD rc.subr.8 r1.19.

Submitted by: Alex Kozlov


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# fdec4b41 20-Jul-2008 Lars Engels <lme@FreeBSD.org>

Properly underline force_depend's parameter.

Reviewed by: brueffer


# 836d250d 31-Mar-2008 Sergey Skvortsov <skv@FreeBSD.org>

Fix punctiation.

Approved by: ru


# 8fe51638 26-Oct-2007 Yaroslav Tykhiy <ytykhiy@gmail.com>

o Add a note that checkyesno takes a variable by its name, not value.
o Improve mdoc(7) markup and style of the paragraph on stop_boot.


# 3d03791b 17-May-2007 Mike Makonnen <mtm@FreeBSD.org>

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


# 6a8cdb5a 27-Dec-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

MFp4:

Document my recent changes to rc.subr(8):
- there is $required_modules now;
- $required_* are checked before invoking a custom start method, too.

MFC after: 1 month


# 3081bf98 22-Aug-2006 Florent Thoumie <flz@FreeBSD.org>

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)


# 016c675d 24-Jul-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

Improve mark-up: References to "start" as an rc.d method
should be tagged with ".Cm". (Refs to "stop" are OK already.)

MFC after: 3 days


# a5fd4f0b 21-Jun-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

Don't forget to touch Dd.


# 1679c7f4 21-Jun-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

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.)


# 8d2e10d0 07-Jun-2006 Florent Thoumie <flz@FreeBSD.org>

Reflect latest changes in rc.subr wrt prefix/etcdir variables being set
automatically by load_rc_config.

With help from: ru (mdoc-fu)
Reviewed by: brueffer
Approved by: cperciva


# 46587ab8 04-Apr-2006 Florent Thoumie <flz@FreeBSD.org>

- 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


# c6136be4 22-Feb-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

Forgot to bump .Dd in the last commit.


# 91387563 22-Feb-2006 Yaroslav Tykhiy <ytykhiy@gmail.com>

Document the relation between $command and $foo_program.

PR: docs/68453
MFC after: 3 days


# 8d52cc90 25-Oct-2005 Yaroslav Tykhiy <ytykhiy@gmail.com>

Use consistent punctuation and vertical indenting around .Dl's.
Wrap a too long line.


# 5a3c72ce 25-Oct-2005 Yaroslav Tykhiy <ytykhiy@gmail.com>

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


# eec3e03e 09-Jul-2004 Ruslan Ermilov <ru@FreeBSD.org>

Fixed markup.


# 5203edcd 03-Jul-2004 Ruslan Ermilov <ru@FreeBSD.org>

Mechanically kill hard sentence breaks and double whitespaces.


# 4f779fd6 27-Feb-2004 Mike Makonnen <mtm@FreeBSD.org>

NetBSD rev. 1.10
successful [is spelled] with only one l

NetBSD rev. 1.12
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


# 62bb7f33 21-Apr-2003 Doug Barton <dougb@FreeBSD.org>

FreeBSD has no systrace(1), and our rc.subr does not support it.

Submitted by: Simon L. Nielsen <simon@nitro.dk>


# 57bd0fc6 26-Dec-2002 Jens Schweikhardt <schweikh@FreeBSD.org>

english(4) police.


# 54e347fb 21-Nov-2002 Gordon Tetlow <gordon@FreeBSD.org>

Update rc(8) manpage to reflect rc.d
Add an rc.subr(8) manpage
Hook rc.subr.8 up to the build.

Submitted by: Mike Makonnen <mtm@identd.net>
Approved by: re@ (bmah)
Obtained from: NetBSD