Understanding init Scripts and the Final Stage of Initialization

Each /etc/init.d script, or init script, contains logic that determines what to do when receiving a start or stop value. The logic might be a simple switch statement for execution, as in this example:

start stop)

stop restart)

restart reload)

reload status)

rhstatus condrestart)

[ -f /var/lock/subsys/smb ] && restart || :

echo $"Usage: $0 {start|stop|restart|status|condrestart}" exit 1

esac

Although the scripts can be used to customize the way that the system runs from poweron, absent the replacement of the kernel, this script approach also means that the system does not have to be halted in total to start, stop, upgrade, or install new services.

Note that not all scripts will use this approach, and that other messages might be passed to the service script, such as restart, reload, or status. Also, not all scripts will respond to the same set of messages (with the exception of start and stop, which they all have to accept by convention) because each service might require special commands.

After all the system scripts have been run, your system is configured and all the necessary system services have been started. If you are using a runlevel other than 5, the final act of the init process is to launch the user shellbash, tcsh, zsh, or any of the many command shells available. The shell launches and you see a login prompt on the screen.

Was this article helpful?

0 0

Post a comment