'\" te .\" Copyright (c) 2000, Sun Microsystems, Inc. All Rights Reserved .\" 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. .\" 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. .\" 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] .TH INIT.D 4 "Aug 17, 2005" .SH NAME init.d \- initialization and termination scripts for changing init states .SH SYNOPSIS .LP .nf \fB/etc/init.d\fR .fi .SH DESCRIPTION .sp .LP \fB/etc/init.d\fR is a directory containing initialization and termination scripts for changing init states. These scripts are linked when appropriate to files in the \fBrc?.d\fR directories, where `\fB?\fR' is a single character corresponding to the init state. See \fBinit\fR(1M) for definitions of the states. .sp .LP The service management facility (see \fBsmf\fR(5)) is the preferred mechanism for service initiation and termination. The \fBinit.d\fR and \fBrc?.d\fR directories are obsolete, and are provided for compatibility purposes only. Applications launched from these directories by \fBsvc.startd\fR(1M) are incomplete services, and will not be restarted on failure. .sp .LP File names in \fBrc?.d\fR directories are of the form \fB[SK]nn\fI\fR\fR, where \fBS\fR means start this job, \fBK\fR means kill this job, and \fBnn\fR is the relative sequence number for killing or starting the job. .sp .LP When entering a state (init S,0,2,3,etc.) the \fBrc[S0-6]\fR script executes those scripts in \fB/etc/rc[S0-6].d\fR that are prefixed with \fBK\fR followed by those scripts prefixed with \fBS\fR. When executing each script in one of the \fB/etc/rc[S0-6] directories, the /sbin/rc[S0-6]\fR script passes a single argument. It passes the argument 'stop' for scripts prefixed with \fBK\fR and the argument 'start' for scripts prefixed with \fBS\fR. There is no harm in applying the same sequence number to multiple scripts. In this case the order of execution is deterministic but unspecified. .sp .LP Guidelines for selecting sequence numbers are provided in \fBREADME\fR files located in the directory associated with that target state. For example, \fB/etc/rc[S0-6].d/README\fR. Absence of a \fBREADME\fR file indicates that there are currently no established guidelines. .sp .LP Do not put \fB/etc/init.d\fR in your \fB$PATH\fR. Having this directory in your \fB$PATH\fR can cause unexpected behavior. The programs in \fB/etc/init.d\fR are associated with \fBinit\fR state changes and, under normal circumstances, are not intended to be invoked from a command line. .SH EXAMPLES .LP \fBExample 1 \fRExample of \fB/sbin/rc2\fR. .sp .LP When changing to init state 2 (multi-user mode, network resources not exported), \fB/sbin/rc2\fR is initiated by the \fBsvc.startd\fR(1M) process. The following steps are performed by \fB/sbin/rc2\fR. .RS +4 .TP 1. In the directory \fB/etc/rc2.d\fR are files used to stop processes that should not be running in state 2. The filenames are prefixed with \fBK\fR. Each \fBK\fR file in the directory is executed (by \fB/sbin/rc2\fR) in alphanumeric order when the system enters init state 2. See example below. .RE .RS +4 .TP 2. Also in the \fBrc2.d\fR directory are files used to start processes that should be running in state 2. As in Step 1, each \fBS\fR file is executed. .RE .sp .LP Assume the file \fB/etc/init.d/netdaemon\fR is a script that will initiate networking daemons when given the argument 'start', and will terminate the daemons if given the argument 'stop'. It is linked to \fB/etc/rc2.d/S68netdaemon\fR, and to \fB/etc/rc0.d/K67netdaemon\fR. The file is executed by \fB/etc/rc2.d/S68netdaemon start\fR when init state 2 is entered and by \fB/etc/rc0.d/K67netdaemon stop\fR when shutting the system down. .SH SEE ALSO .sp .LP \fBsvcs\fR(1), \fBinit\fR(1M), \fBsvc.startd\fR(1M), \fBsvccfg\fR(1M), \fBsmf\fR(5) .SH NOTES .sp .LP Solaris now provides an expanded mechanism, which includes automated restart, for applications historically started via the init script mechanism. The Service Management Facility (introduced in \fBsmf\fR(5)) is the preferred delivery mechanism for persistently running applications. Existing \fBinit.d\fR scripts will, however, continue to be executed according to the rules in this manual page. The details of execution in relation to managed services are available in \fBsvc.startd\fR(1M). .sp .LP On earlier Solaris releases, a script named with a suffix of '.sh' would be sourced, allowing scripts to modify the environment of other scripts executed later. This behavior is no longer supported; for altering the environment in which services are run, see the \fBsetenv\fR subcommand in \fBsvccfg\fR(1M). .sp .LP \fB/sbin/rc2\fR has references to the obsolescent \fBrc.d\fR directory. These references are for compatibility with old \fBINSTALL\fR scripts. New \fBINSTALL\fR scripts should use the \fBinit.d\fR directory for related executables. The same is true for the \fBshutdown.d\fR directory.