| :: [linux] How to set up system initialization scripts in RH 8.0 :: | ||||
| HOME |
|
When an RH 8.0 system boots up, it goes through
many stages. You can find a good reference to the boot process of RH 8.0
here. I will
describe what happens when the boot process reaches a stage where it runs the
init process.
The init process first runs the /etc/rc.d/rc.sysinit script. Basically, rc.sysinit takes
care of everything that your system needs to have done at system initialization.
For example, most systems use a clock, so on them rc.sysinit reads the /etc/sysconfig/clock configuration file to initialize the
clock.
The init command then runs the /etc/inittab script, which runs the system at a default
runlevel (usually 5).
The init program starts all of the
background processes by looking in the appropriate rc directory for the runlevel
specified as default in /etc/inittab. The rc directories are numbered to
corresponds to the runlevel they represent. For instance, /etc/rc.d/rc5.d/ is
the directory for runlevel five. When booting to runlevel 5, the init program
looks in the /etc/rc.d/rc5.d/ directory to determine which processes to start
and stop.There are many such scripts in this directory, which are actually links
to /etc/rc.d/init.d. Some of them start with the capital letter "K" (Called
K-Scripts) and some start with "S" (called Start-scripts). The init command
first stops all of the K symbolic links in the directory by issuing the /etc/rc.d/init.d/<command> stop command, where
<command> is the process to be killed. It then starts all of the S
symbolic links by issuing /etc/rc.d/init.d/<command>
start.
Below I present the S-script that i copied for
DHCPD. This should serve as a general template in future
#!/bin/bash test -x /usr/sbin/dhcpd || exit 0 RETVAL=0 # prog="dhcpd" start() { stop() {
reload() { status_at() { case "$1" in exit $? |