2 .\" Copyright (c) 2000, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH INIT.D 4 "May 13, 2017"
8 init.d \- initialization and termination scripts for changing init states
17 \fB/etc/init.d\fR is a directory containing initialization and termination
18 scripts for changing init states. These scripts are linked when appropriate to
19 files in the \fBrc?.d\fR directories, where `\fB?\fR' is a single character
20 corresponding to the init state. See \fBinit\fR(8) for definitions of the
24 The service management facility (see \fBsmf\fR(5)) is the preferred mechanism
25 for service initiation and termination. The \fBinit.d\fR and \fBrc?.d\fR
26 directories are obsolete, and are provided for compatibility purposes only.
27 Applications launched from these directories by \fBsvc.startd\fR(8) are
28 incomplete services, and will not be restarted on failure.
31 File names in \fBrc?.d\fR directories are of the form \fB[SK]nn\fI<init.d
32 filename>\fR\fR, where \fBS\fR means start this job, \fBK\fR means kill this
33 job, and \fBnn\fR is the relative sequence number for killing or starting the
37 When entering a state (init S,0,2,3,etc.) the \fBrc[S0-6]\fR script executes
38 those scripts in \fB/etc/rc[S0-6].d\fR that are prefixed with \fBK\fR followed
39 by those scripts prefixed with \fBS\fR. When executing each script in one of
40 the \fB/etc/rc[S0-6] directories, the /sbin/rc[S0-6]\fR script passes a single
41 argument. It passes the argument 'stop' for scripts prefixed with \fBK\fR and
42 the argument 'start' for scripts prefixed with \fBS\fR. There is no harm in
43 applying the same sequence number to multiple scripts. In this case the order
44 of execution is deterministic but unspecified.
47 Guidelines for selecting sequence numbers are provided in \fBREADME\fR files
48 located in the directory associated with that target state. For example,
49 \fB/etc/rc[S0-6].d/README\fR. Absence of a \fBREADME\fR file indicates that
50 there are currently no established guidelines.
53 Do not put \fB/etc/init.d\fR in your \fB$PATH\fR. Having this directory in your
54 \fB$PATH\fR can cause unexpected behavior. The programs in \fB/etc/init.d\fR
55 are associated with \fBinit\fR state changes and, under normal circumstances,
56 are not intended to be invoked from a command line.
59 \fBExample 1 \fRExample of \fB/sbin/rc2\fR.
62 When changing to init state 2 (multi-user mode, network resources not
63 exported), \fB/sbin/rc2\fR is initiated by the \fBsvc.startd\fR(8) process.
64 The following steps are performed by \fB/sbin/rc2\fR.
69 In the directory \fB/etc/rc2.d\fR are files used to stop processes that
70 should not be running in state 2. The filenames are prefixed with \fBK\fR. Each
71 \fBK\fR file in the directory is executed (by \fB/sbin/rc2\fR) in alphanumeric
72 order when the system enters init state 2. See example below.
77 Also in the \fBrc2.d\fR directory are files used to start processes that
78 should be running in state 2. As in Step 1, each \fBS\fR file is executed.
82 Assume the file \fB/etc/init.d/netdaemon\fR is a script that will initiate
83 networking daemons when given the argument 'start', and will terminate the
84 daemons if given the argument 'stop'. It is linked to
85 \fB/etc/rc2.d/S68netdaemon\fR, and to \fB/etc/rc0.d/K67netdaemon\fR. The file
86 is executed by \fB/etc/rc2.d/S68netdaemon start\fR when init state 2 is entered
87 and by \fB/etc/rc0.d/K67netdaemon stop\fR when shutting the system down.
91 \fBsvcs\fR(1), \fBinit\fR(8), \fBsvc.startd\fR(8), \fBsvccfg\fR(8),
95 Solaris now provides an expanded mechanism, which includes automated restart,
96 for applications historically started via the init script mechanism. The
97 Service Management Facility (introduced in \fBsmf\fR(5)) is the preferred
98 delivery mechanism for persistently running applications. Existing \fBinit.d\fR
99 scripts will, however, continue to be executed according to the rules in this
100 manual page. The details of execution in relation to managed services are
101 available in \fBsvc.startd\fR(8).
104 On earlier Solaris releases, a script named with a suffix of '.sh' would be
105 sourced, allowing scripts to modify the environment of other scripts executed
106 later. This behavior is no longer supported; for altering the environment in
107 which services are run, see the \fBsetenv\fR subcommand in \fBsvccfg\fR(8).