'\" 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 5 "May 13, 2017" .SH NAME init.d \- initialization and termination scripts for changing init states .SH SYNOPSIS .LP .nf \fB/etc/init.d\fR .fi .SH DESCRIPTION .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(8) for definitions of the states. .sp .LP The service management facility (see \fBsmf\fR(7)) 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(8) 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(8) 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 .LP .BR svcs (1), .BR smf (7), .BR init (8), .BR svc.startd (8), .BR svccfg (8) .SH NOTES .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(7)) 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(8). .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(8).