Customizing UNIX system startup

System state directories

System states 0, 1, 2, and 3 each have a directory of files that are executed in transitions to and from that state. These directories are /etc/rc0.d, /etc/rc1.d, /etc/rc2.d, and /etc/rc3.d, respectively. States 2 and 3 also execute files in the /etc/dinit.d directory. Most files in these directories are linked to files in the /etc/init.d directory. Typically, their purpose is to start and stop various system services or daemons.

The system state files in /etc/dinit.d are named according to the following conventions:




Each filename consists of three parts:

S or K
The first letter specifies whether the process should be started (S) or killed (K) on entering the new system state.

The next two characters form a number between 00 and 99. They show the order in which the files will be started (S00, S01, S02, and so on) or killed (K00, K01, K02, and so on).

The rest of the filename is the name of the file in the /etc/init.d directory to which this file is linked.

How system state files are used

The /etc/init.d/lp shell script is linked to the /etc/dinit.d/S80lp and /etc/rc0.d/K20lp files. When run with the start option, the /etc/init.d/lp script executes /usr/lib/lpsched to start the printing scheduler. When run with the stop option, it executes /usr/lib/lpshut to kill the printing scheduler.

When you run init 2, init runs the scripts in /etc/dinit.d, one of which is S80lp. The script S80lp is executed with the start option, as follows:

sh S80lp start

Similarly, when you run init 0, /etc/rc0.d/K20lp is executed with the stop option:

sh K20lp stop

Running either of these scripts is the same as running /etc/init.d/lp with the appropriate start or stop option.

Creating your own system state files

Because system state files are shell scripts, you can read them to see what they do. You can also change the files, although it is preferable to create your own versions because the delivered scripts may change in future releases.

Follow these rules when creating your own scripts:

Next topic: Changing the default system state
Previous topic: System states

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004