1 .\" $NetBSD: rc.8,v 1.32 2009/09/11 18:17:04 apb Exp $
3 .\" Copyright (c) 2000-2004 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
30 .Dd September 11, 2009
37 .Nd startup and shutdown scripts
44 is the command script which controls the startup of various services,
47 as part of the process of entering the automatic reboot to multi-user startup,
48 or after the single user mode shell has exited.
51 is starting the automatic reboot process,
53 is invoked with the argument of
57 is the command script which shuts down various services, and is invoked by
59 as part of the process of shutting down the system.
62 is the directory which contains various
64 scripts, one for each service,
70 and as necessary during system operation to stop, start, restart, reload,
71 or otherwise control the service.
79 shell functions to use.
87 scripts from performing the check for already running processes
88 (thus speeding up the boot process).
91 speedup won't occur when
93 is started up after exiting the single-user shell.
105 and assigns the result to a variable.
107 Calls each script in turn using
115 and sources the script in a subshell.
118 suffix then it is sourced directly into the current shell.
120 The output from the above steps is sent to a post-processor.
123 is false, then the post-processor displays the output.
126 is true, then the post-processor invokes the command specified in
128 once for each line, without otherwise displaying the output.
133 to display nothing at all, and
135 to display a spinning symbol on the console.
136 Regardless of the value of
138 the post-processor saves the output in
139 .Pa /var/run/rc.log .
141 .Ss Operation of rc.shutdown
148 shell functions to use.
152 to order the files in
160 reverses that order, and assigns the result to a variable.
162 Calls each script in turn using
170 and sources the script in a subshell.
173 suffix then it is sourced directly into the current shell.
175 .Ss Contents of rc.d/
179 The following file naming conventions are currently used in
181 .Bl -tag -width ALLUPPERCASExx -offset indent
185 to ensure that certain operations are performed before others.
186 In order of startup, these are:
187 .Bl -tag -width NETWORKINGxx
189 Ensure basic network services are running, including general
190 network configuration
195 Ensure basic services (such as
201 exist for services that start early (such as
203 because they're required by
207 Before all general purpose daemons such as
213 Before user login services
220 as well as before services which might run commands as users
227 Scripts that are to be sourced into the current shell rather than a subshell
231 Extreme care must be taken in using this, as the startup sequence will
232 terminate if the script does.
233 .Pa /etc/rc.d/bootconf.sh
234 uses this behaviour to allow the user to select a different
235 configuration (including
239 Scripts that are sourced in a subshell.
240 The boot does not stop if such a script terminates with a non-zero status,
241 but a script can stop the boot if necessary by invoking the
247 Each script should contain
249 keywords, especially an appropriate
253 The scripts are expected to support at least the following arguments:
254 .Bl -tag -width restart -offset indent
257 This should check that the service is to be started as specified by
259 Also checks if the service is already running and refuses to start if
261 This latter check is not performed by standard
263 scripts if the system is starting directly to multi-user mode, to
264 speed up the boot process.
266 If the service is to be started as specified by
269 This should check that the service is running and complain if it's not.
276 If the script starts a process (rather than performing a one-off
277 operation), show the status of the process.
278 Otherwise it's not necessary to support this argument.
279 Defaults to displaying the process ID of the program (if running).
281 If the script starts a process (rather than performing a one-off
282 operation), wait for the command to exit.
283 Otherwise it's not necessary to support this argument.
287 variables are used to control the startup of the service (if any).
290 Other arguments (such as
293 etc) can be added if necessary.
295 The argument may have one of the following prefixes to alter its operation:
296 .Bl -tag -width "force" -offset indent
298 Skip the check for an existing running process.
304 check, ignores a failure result from any of the prerequisite checks,
305 executes the command, and always returns a zero exit status.
311 check, but performs all other prerequisite tests.
314 In order to simplify scripts, the
320 .Bl -tag -width /etc/rc.shutdown -compact
322 Startup script called by
325 Directory containing control scripts for each service.
326 .It Pa /etc/rc.shutdown
327 Shutdown script called by
332 functions used by various scripts.
334 System startup configuration file.
335 .It Pa /var/run/rc.log
353 support was implemented in
357 .Aq lukem@NetBSD.org .
358 The post-processor, support for
360 and saving output to a file, was implemented in