296 lines
7.6 KiB
Groff
296 lines
7.6 KiB
Groff
.\" $NetBSD: rc.8,v 1.18 2002/01/31 01:28:53 lukem Exp $
|
|
.\"
|
|
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
.\" by Luke Mewburn.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the NetBSD
|
|
.\" Foundation, Inc. and its contributors.
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
.\" contributors may be used to endorse or promote products derived
|
|
.\" from this software without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd January 31, 2002
|
|
.Dt RC 8
|
|
.Os
|
|
.Sh NAME
|
|
.Nm rc ,
|
|
.Nm rc.shutdown ,
|
|
.Nm rc.d/
|
|
.Nd startup and shutdown scripts
|
|
.Sh SYNOPSIS
|
|
.Nm rc
|
|
.Nm rc.shutdown
|
|
.Nm rc.d/
|
|
.Sh DESCRIPTION
|
|
.Nm
|
|
is the command script which controls the startup of various services,
|
|
and is invoked by
|
|
.Xr init 8
|
|
as part of the process of entering the automatic reboot to multi-user startup,
|
|
or after the single user mode shell has exited.
|
|
If
|
|
.Xr init 8
|
|
is starting the automatic reboot process,
|
|
.Nm
|
|
is invoked with the argument of
|
|
.Sq autoboot .
|
|
.Pp
|
|
.Nm rc.shutdown
|
|
is the command script which shuts down various services, and is invoked by
|
|
.Xr shutdown 8
|
|
as part of the process of shutting down the system.
|
|
.Pp
|
|
.Nm rc.d/
|
|
is the directory which contains various scripts, one for each service,
|
|
which are called by
|
|
.Nm
|
|
at startup,
|
|
.Nm rc.shutdown
|
|
at shutdown,
|
|
and as necessary during system operation to stop, start, restart, reload,
|
|
(etc) the service.
|
|
.Ss Operation of rc
|
|
.Bl -enum
|
|
.It
|
|
Source
|
|
.Pa /etc/rc.subr
|
|
to load various shell functions to use.
|
|
.It
|
|
If autobooting, set
|
|
.Dv $autoboot
|
|
to
|
|
.Sq yes ,
|
|
and enable a flag which prevents the
|
|
.Nm rc.d
|
|
scripts from performing the check for already running processes
|
|
(thus speeding up the boot process).
|
|
This speedup won't occur when
|
|
.Nm
|
|
is started up after exiting the single-user shell.
|
|
.It
|
|
Invoke
|
|
.Xr rcorder 8
|
|
to order the files in
|
|
.Pa /etc/rc.d/
|
|
that do not have a
|
|
.Dq nostart
|
|
keyword (refer to
|
|
.Xr rcorder 8 's
|
|
.Fl s
|
|
flag),
|
|
and assigns the result to a variable.
|
|
.It
|
|
Calls each script in turn using run_rc_script() (from
|
|
.Pa /etc/rc.subr ) ,
|
|
which sets
|
|
.Dv $1
|
|
to
|
|
.Sq start ,
|
|
and sources the script in a subshell.
|
|
If the script has a
|
|
.Sq .sh
|
|
suffix then it is sourced directly into the current shell.
|
|
.El
|
|
.Ss Operation of rc.shutdown
|
|
.Bl -enum
|
|
.It
|
|
Source
|
|
.Pa /etc/rc.subr
|
|
to load various shell functions to use.
|
|
.It
|
|
Invoke
|
|
.Xr rcorder 8
|
|
to order the files in
|
|
.Pa /etc/rc.d/
|
|
that have a
|
|
.Dq shutdown
|
|
keyword (refer to
|
|
.Xr rcorder 8 's
|
|
.Fl k
|
|
flag),
|
|
reverses that order, and assigns the result to a variable.
|
|
.It
|
|
Calls each script in turn using run_rc_script() (from
|
|
.Pa /etc/rc.subr ) ,
|
|
which sets
|
|
.Dv $1
|
|
to
|
|
.Sq stop ,
|
|
and sources the script in a subshell.
|
|
If the script has a
|
|
.Sq .sh
|
|
suffix then it is sourced directly into the current shell.
|
|
.El
|
|
.Ss Contents of rc.d/
|
|
.Nm rc.d/
|
|
is located in
|
|
.Pa /etc/rc.d .
|
|
The following file naming conventions are currently used in
|
|
.Nm rc.d/ :
|
|
.Bl -tag -width ALLUPPERCASE -offset indent
|
|
.It ALLUPPERCASE
|
|
Scripts that are
|
|
.Sq placeholders
|
|
to ensure that certain operations are done before others.
|
|
In order of startup, these are:
|
|
.Bl -tag -width NETWORKING
|
|
.It NETWORKING
|
|
Ensure basic network services are running, including general
|
|
network configuration
|
|
.Pq Pa network
|
|
and
|
|
.Pa dhclient .
|
|
.It SERVERS
|
|
Ensure basic services (such as
|
|
.Pa NETWORKING ,
|
|
.Pa ppp ,
|
|
.Pa syslogd ,
|
|
and
|
|
.Pa kdc )
|
|
exist for services that start early (such as
|
|
.Pa named ) ,
|
|
because they're required by
|
|
.Pa DAEMON
|
|
below.
|
|
.It DAEMON
|
|
Before all general purpose daemons such as
|
|
.Pa dhcpd ,
|
|
.Pa lpd ,
|
|
and
|
|
.Pa ntpd .
|
|
.It LOGIN
|
|
Before user login services
|
|
.Pa ( inetd ,
|
|
.Pa telnetd ,
|
|
.Pa rshd ,
|
|
.Pa sshd ,
|
|
and
|
|
.Pa xdm ) ,
|
|
as well as before services which might run commands as users
|
|
.Pa ( cron ,
|
|
.Pa postfix ,
|
|
and
|
|
.Pa sendmail ) .
|
|
.El
|
|
.It 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.
|
|
.Pa /etc/rc.d/bootconf.sh
|
|
uses this behaviour to allow the user to select a different
|
|
configuration (including
|
|
.Pa /etc/rc.conf )
|
|
early in the boot.
|
|
.It bar
|
|
Scripts that are sourced in a subshell.
|
|
These can stop the boot if necessary with the following shell
|
|
commands:
|
|
.Bd -literal -offset
|
|
if [ "$autoboot" = yes ]; then
|
|
kill -TERM $$
|
|
fi
|
|
exit 1
|
|
.Ed
|
|
.Pp
|
|
Note that this should be used sparingly!
|
|
.El
|
|
.Pp
|
|
The scripts are expected to support at least the following arguments:
|
|
.Bl -tag -width restart -offset indent
|
|
.It start
|
|
Start the service.
|
|
This should check that the service is to be started as specified by
|
|
.Xr rc.conf 5 .
|
|
Also checks if the service is already running and refuses to start if
|
|
it is.
|
|
This latter check is not performed by standard
|
|
.Nx
|
|
scripts if the system is starting directly to multi-user mode, to
|
|
speed up the boot process.
|
|
If
|
|
.Sq forcestart
|
|
is given, ignore the rc.conf check and start anyway.
|
|
.It stop
|
|
If the service is to be started as specified by
|
|
.Xr rc.conf 5 ,
|
|
stop the service.
|
|
This should check that the service is running and complain if it's not.
|
|
If
|
|
.Sq forcestop
|
|
is given, ignore the rc.conf check and attempt to stop.
|
|
.It restart
|
|
Effectively perform a stop then a start.
|
|
.It status
|
|
If the script starts a process (rather than performing a one-off
|
|
operation), show the status of the process.
|
|
Otherwise it's not necessary to support this argument.
|
|
Defaults to displaying the process ID of the program (if running).
|
|
.It rcvar
|
|
Display which
|
|
.Pa /etc/rc.conf
|
|
variables are used to control the startup of the service (if any).
|
|
.El
|
|
.Pp
|
|
Other arguments (such as
|
|
.Sq reload ,
|
|
.Sq dumpdb ,
|
|
etc) can be added if necessary.
|
|
.Pp
|
|
In order to simplify scripts, the run_rc_command() function from
|
|
.Pa /etc/rc.subr
|
|
may be used.
|
|
.Sh FILES
|
|
.Bl -tag -width /etc/rc.shutdown -compact
|
|
.It Pa /etc/rc
|
|
Startup script called by
|
|
.Xr init 8 .
|
|
.It Pa /etc/rc.d/
|
|
Directory containing control scripts for each service.
|
|
.It Pa /etc/rc.shutdown
|
|
Shutdown script called by
|
|
.Xr shutdown 8 .
|
|
.It Pa /etc/rc.subr
|
|
Contains functions used by various scripts.
|
|
.El
|
|
.Sh SEE ALSO
|
|
.Xr rc.conf 5 ,
|
|
.Xr init 8 ,
|
|
.Xr rcorder 8 ,
|
|
.Xr reboot 8 ,
|
|
.Xr shutdown 8
|
|
.Sh HISTORY
|
|
The
|
|
.Nm
|
|
command appeared in
|
|
.Bx 4.0 .
|
|
The
|
|
.Pa /etc/rc.d
|
|
support was implemented in
|
|
.Nx 1.5
|
|
by Luke Mewburn <lukem@netbsd.org>.
|