rc(8)
- NetBSD Manual Pages
RC(8) NetBSD System Manager's Manual RC(8)
NAME
rc, rc.shutdown, rc.d/ - startup and shutdown scripts
SYNOPSIS
rc
rc.shutdown
rc.d/
DESCRIPTION
rc is the command script which controls the startup of various services,
and is invoked by init(8) as part of the process of entering the automat-
ic reboot to multi-user startup, or after the single user mode shell has
exited. If init(8) is starting the automatic reboot process, rc is in-
voked with the argument of `autoboot'.
rc.shutdown is the command script which shuts down various services, and
is invoked by shutdown(8) as part of the process of shutting down the
system.
rc.d/ is the directory which contains various scripts, one for each ser-
vice, which are called by rc at startup, rc.shutdown at shutdown, and as
necessary during system operation to stop, start, restart, reload, (etc)
the service.
Operation of rc
1. Source /etc/rc.subr to load various shell functions to use.
2. If autobooting, set $autoboot to `yes', and enable a flag which pre-
vents the rc.d scripts from performing the check for already running
processes (thus speeding up the boot process). This speedup won't
occur when rc is started up after exiting the single-user shell.
3. Invoke rcorder(8) to order the files in /etc/rc.d/ that do not have
a ``nostart'' keyword (refer to rcorder(8)'s -s flag), and assigns
the result to a variable.
4. Calls each script in turn using run_rc_script() (from /etc/rc.subr),
which sets $1 to `start', and sources the script in a subshell. If
the script has a `.sh' suffix then it is sourced directly into the
current shell.
Operation of rc.shutdown
1. Source /etc/rc.subr to load various shell functions to use.
2. Invoke rcorder(8) to order the files in /etc/rc.d/ that have a
``shutdown'' keyword (refer to rcorder(8)'s -k flag), reverses that
order, and assigns the result to a variable.
3. Calls each script in turn using run_rc_script() (from /etc/rc.subr),
which sets $1 to `stop', and sources the script in a subshell. If
the script has a `.sh' suffix then it is sourced directly into the
current shell.
Contents of rc.d/
rc.d/ is located in /etc/rc.d. The following file naming conventions are
currently used in rc.d/:
ALLUPPERCASE Scripts that are `placeholders' to ensure that cer-
tain operations are done before others, such as:
DAEMON before all general purpose daemons
LOGIN before user login processes
NETWORK ensure basic network services are running
SERVERS ensure basic services exist for services
that start early.
foo.sh Scripts that are to be sourced into the current shell
rather than a subshell. Extreme care must be taken
in using this, as the startup sequence will terminate
if the script does. /etc/rc.d/bootconf.sh uses this
behaviour to allow the user to select a different
configuration (including /etc/rc.conf) early in the
boot.
bar Scripts that are sourced in a subshell. These can
stop the boot if necessary with the following shell
commands:
if [ "$autoboot" = yes ]; then
kill -TERM $$
fi
exit 1
Note that this should be used sparingly!
The scripts are expected to support at least the following arguments:
start Start the program. This should check that the program is
to be started as specified by rc.conf(5). If `forcestart'
is given, ignore the rc.conf check and start anyway.
stop If the program is to be started as specified by
rc.conf(5), stop the program. This should check that the
program is running and complain if it's not. If
`forcestop' is given, ignore the rc.conf check and attempt
to stop.
restart Effectively perform a stop then a start.
status Show the status of the program. Defaults to displaying
the process ID of the process (if running).
Other arguments (such as `reload', `dumpdb', etc) can be added if neces-
sary.
In order to simplify scripts, the run_rc_command() function from
/etc/rc.subr may be used.
FILES
/etc/rc Startup script called by init(8).
/etc/rc.d/ Directory containing control scripts for each service.
/etc/rc.shutdown Shutdown script called by shutdown(8).
/etc/rc.subr Contains functions used by various scripts.
SEE ALSO
rc.conf(5), init(8), rcorder(8), reboot(8), shutdown(8)
HISTORY
The rc command appeared in 4.0BSD. The /etc/rc.d support was implemented
in NetBSD 1.5 by Luke Mewburn <lukem@netbsd.org>.
NetBSD 1.5 August 16, 2000 2
Powered by man-cgi (2024-03-20).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.