Changing scripts in /etc/rc2.d
Upon entering init state 2 (multiuser mode) from
either a higher init state (3-6) or from single-user mode,
init executes the /etc/rc2
script according to the instructions in /etc/inittab.
The rc2 script sets certain environment variables
and runs scripts in the /etc/rc2.d directory.
Some of the scripts in rc2.d run scripts in
subdirectories of the rc.d directory.
This section describes the scripts in the
/etc/rc2.d directory that are run by rc2
and explains the steps for adding your own script. The
rc2(ADM)
manual page describes the other scripts that rc2 runs.
``/etc/rc2.d scripts''
gives a brief description of some of
the scripts in /etc/rc2.d.
/etc/rc2.d scripts
Script
|
Description
|
S00MDAC
|
starts Mylex disk array monitor
|
P00SYSINIT
|
starts kernel message logger
|
S00VDISK
|
configures virtual disk arrays
|
I01MOUNTFSYS
|
mounts filesystems specified in /etc/default/filesys
|
P03RECOVERY
|
tidies up vi editing sessions after a crash
|
P04CLEAN
|
removes temporary files
|
P05RMTMPFILES
|
removes temporary files
|
P15HWDNLOAD
|
downloads hardware
|
P16KERNINIT
|
starts, process accounting, network,
and other kernel initialization
|
P20sysetup
|
configures print system and generates /etc/systemid
|
P21perf
|
starts system accounting
|
S25pm
|
starts power management event routing and servicing daemon
|
S35dlpi
|
configures the network card driver interface
|
P70uucp
|
cleans up UUCP lock files
|
P75cron
|
starts cron daemon
|
S80lp
|
starts lpsched and net utilities
|
S85tcp
|
starts TCP/IP, name service, and routing
|
P86mmdf
|
starts mmdf deliver daemon
|
P86scologin
|
starts scologin
|
P87USRDAEMON
|
starts user daemons
|
P88USRDEFINE
|
executes user-definable commands after boot
|
S89hostmib
|
starts host MIB service
|
S89nfs
|
starts NFS service
|
P90RESERVED
|
mails fsck output saved during autoboot to root
|
S95calserver
|
starts calendar daemon
|
S95docview
|
starts DocView Apache server
|
S99apcssd
|
starts UPS port monitor
|
The /etc/rc2.d directory on your system may contain
scripts other than the ones listed in the table.
This is because during installation,
many add-on programs insert their own daemon-initialization
scripts in this directory.
This directory may also include scripts that clean up the
temporary or lock files for an add-on program.
You can write your own scripts to run when
the system enters init state 2.
For example, you can write a script that sets up a RAM
disk or starts a network and add it to /etc/rc2.d.
The following factors should be considered when writing a
system startup script to be placed in rc2.d :
-
When going from a higher or lower init state to
init state 2, files that begin with an
``S'', ``P'', or ``I''
are executed with the start option.
-
When changing from a higher init state (3-9) to
init state 2, scripts in rc2.d that begin
with a ``K'' are executed with the stop option.
-
Files that begin with characters other than
``S'', ``P'', ``I'', or ``K''
are ignored.
-
Files are executed in
order of their filenames sorted according to the
ASCII collation sequence from their second
character onwards (see
rc2(ADM)
and
prc_sync(ADM)
for more details).
Scripts that start with ``S'' or ``I''
(or ``K'' for /etc/rc0.d shutdown scripts)
are executed serially; those beginning with ``P'' are
executed concurrently if they form a contiguous sequence between
``S'' or ``I'' (or ``K'') scripts.
Processing of ``S'' or ``I''
(or ``K'') scripts does not start
until all previous scripts have exited.
``Valid filename characters''
gives, in sort-sequence order (left to right),
the ASCII characters that are valid for naming files.
Valid filename characters
#
|
%
|
+
|
,
|
-
|
.
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
:
|
=
|
?
|
@
|
A
|
B
|
C
|
D
|
E
|
F
|
G
|
H
|
I
|
J
|
K
|
L
|
M
|
N
|
O
|
P
|
Q
|
R
|
S
|
T
|
U
|
V
|
W
|
X
|
Y
|
Z
|
^
|
_
|
a
|
b
|
c
|
d
|
e
|
f
|
g
|
h
|
i
|
j
|
k
|
l
|
m
|
n
|
o
|
p
|
q
|
r
|
s
|
t
|
u
|
v
|
w
|
x
|
y
|
|
|
|
|
|
|
|
-
Your script may rely on the existence of services or daemons
(such as network services, the cron
daemon, or the print scheduler) started by other scripts.
For example, if your script depends upon certain filesystems
being mounted, make sure that you name your script so that
it runs after the I01MOUNTFSYS script.
(When you add a new filesystem with mkdev fs,
the appropriate files are updated with the information
necessary to mount the new filesystem when the system
enters multiuser mode.)
To add a function to the initialization procedure:
-
Write a script that performs the desired function.
-
Test the script to make certain it behaves as expected.
Be sure any environment variables used in the script are
defined at startup.
-
Name the file so that it begins with the uppercase letter
``P'', ``S'', ``I'', or ``K''
followed by a two-digit number indicating the order
in which it should be executed relative to the other files
in the directory, and ends with a name that describes the script's function.
For example,
S80lp handles print service startup. It will be
executed after any script that begins with S79, and
before any that begins with S81.
You must follow this naming convention to ensure that your
script is executed at the proper time.
Note that a set of scripts whose names start with
P77, P78, and P79 will be executed
concurrently. S80lp will not start until they have all
exited.
-
Copy the script into the /etc/rc2.d
directory so that it is executed by rc2
when the system enters (or leaves) multiuser mode.
If the function that you want to add is in the same category
as functions performed by a script already located in
/etc/rc2.d,
simply edit the existing script to add the new function.
For example,
you can add a function related to UUCP to the file
P70uucp.
You can also edit any script to tailor it to your needs.
For example, to start process accounting, remove the
appropriate comments from the
P16KERNINIT
file. Remember to back up the original script before modifying it.
Next topic:
Starting daemons on a trusted system
Previous topic:
inittab powerfail keywords
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005