1 .\" $NetBSD: rc.8,v 1.36 2010/05/14 16:19:58 jruoho 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.
38 .Nd startup and shutdown scripts
46 is the command script which controls the startup of various services,
49 as part of the process of entering the automatic reboot to multi-user startup,
50 or after the single user mode shell has exited.
53 is starting the automatic reboot process,
55 is invoked with the argument of
59 is a command script to which local boot-time actions can be added.
60 It is (nearly) the last thing invoked by
65 is the command script which shuts down various services, and is invoked by
67 as part of the process of shutting down the system.
70 is the directory which contains various
72 scripts, one for each service,
78 and as necessary during system operation to stop, start, restart, reload,
79 or otherwise control the service.
87 shell functions to use.
95 scripts from performing the check for already running processes
96 (thus speeding up the boot process).
99 speedup won't occur when
101 is started up after exiting the single-user shell.
105 to order the files in
113 and assigns the result to a variable.
115 Calls each script in turn using
123 and sources the script in a subshell.
126 suffix then it is sourced directly into the current shell.
128 The output from the above steps is sent to a post-processor.
131 is false, then the post-processor displays the output.
134 is true, then the post-processor invokes the command specified in
136 once for each line, without otherwise displaying the output.
141 to display nothing at all, and
143 to display a spinning symbol on the console.
144 Regardless of the value of
146 the post-processor saves the output in
147 .Pa /var/run/rc.log .
149 .Ss Operation of rc.shutdown
156 shell functions to use.
160 to order the files in
168 reverses that order, and assigns the result to a variable.
170 Calls each script in turn using
178 and sources the script in a subshell.
181 suffix then it is sourced directly into the current shell.
183 .Ss Contents of rc.d/
187 The following file naming conventions are currently used in
189 .Bl -tag -width ALLUPPERCASExx -offset indent
193 to ensure that certain operations are performed before others.
194 In order of startup, these are:
195 .Bl -tag -width NETWORKINGxx
197 Ensure basic network services are running, including general
198 network configuration
203 Ensure basic services (such as
209 exist for services that start early (such as
211 because they're required by
215 Before all general purpose daemons such as
221 Before user login services
228 as well as before services which might run commands as users
235 Scripts that are to be sourced into the current shell rather than a subshell
239 Extreme care must be taken in using this, as the startup sequence will
240 terminate if the script does.
241 .Pa /etc/rc.d/bootconf.sh
242 uses this behaviour to allow the user to select a different
243 configuration (including
247 Scripts that are sourced in a subshell.
248 The boot does not stop if such a script terminates with a non-zero status,
249 but a script can stop the boot if necessary by invoking the
255 Each script should contain
257 keywords, especially an appropriate
261 The scripts are expected to support at least the following arguments:
262 .Bl -tag -width restart -offset indent
265 This should check that the service is to be started as specified by
267 Also checks if the service is already running and refuses to start if
269 This latter check is not performed by standard
271 scripts if the system is starting directly to multi-user mode, to
272 speed up the boot process.
274 If the service is to be started as specified by
277 This should check that the service is running and complain if it's not.
284 If the script starts a process (rather than performing a one-off
285 operation), show the status of the process.
286 Otherwise it's not necessary to support this argument.
287 Defaults to displaying the process ID of the program (if running).
289 If the script starts a process (rather than performing a one-off
290 operation), wait for the command to exit.
291 Otherwise it's not necessary to support this argument.
295 variables are used to control the startup of the service (if any).
298 Other arguments (such as
301 etc) can be added if necessary.
303 The argument may have one of the following prefixes to alter its operation:
304 .Bl -tag -width "force" -offset indent
306 Skip the check for an existing running process.
312 check, ignores a failure result from any of the prerequisite checks,
313 executes the command, and always returns a zero exit status.
319 check, but performs all other prerequisite tests.
322 In order to simplify scripts, the
328 .Bl -tag -width /etc/rc.shutdown -compact
330 Startup script called by
333 Directory containing control scripts for each service.
335 Local startup script.
336 .It Pa /etc/rc.shutdown
337 Shutdown script called by
342 functions used by various scripts.
344 System startup configuration file.
345 .It Pa /var/run/rc.log
358 .%T The Design and Implementation of the NetBSD rc.d system
359 .%I USENIX Association
360 .%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference
362 .%U http://www.usenix.org/publications/library/proceedings/usenix01/freenix01/full_papers/mewburn/mewburn.pdf
371 support was implemented in
375 .Aq lukem@NetBSD.org .
376 The post-processor, support for
378 and saving output to a file, was implemented in