init - initialize processes at startup
/usr/sbin/init
The init utility is the first process that runs when the Interix subsystem starts. It is similar to /etc/init on traditional UNIX systems, except that the Interix version does not use /etc/inittab because Interix runs only at level 2.
When init starts, it executes in alphabetic order all scripts in /etc/rc2.d using the following command:
/bin/ksh /etc/rc2.d/scriptname start >> /var/adm/lob/init.log
The /etc/rc2.d directory does not contain the scripts themselves, but rather contains symbolic links to the actual scripts located in /etc/init.d. The scripts are typically used to start and stop Interix daemons or to perform other tasks required when the system initializes or shuts down. The scripts in /etc/init.d can be named to indicate their function, while the symbolic links in /etc/rc2.d are named according to whether the script is to be run at startup or shutdown and according to the order in which the scripts are to be run. The names of the links in /etc/rc2.d begin either with the letter S or K, followed by a two-digit number that determines the sequence in which the scripts are executed.
The init utility has two states: up and down. When init starts, it starts in the up state, and only the scripts of the links whose names start with the letter S are executed. If init receives a SIGHUP signal, it switches from one state to the other. If this places init into the down state, it executes the scripts of the links whose names start with the letter K using the following command:
/bin/ksh /etc/rc2.d/scriptname stop >> /var/adm/log/init.log
If init receives a SIGTERM, SIGKILL, SIGQUIT signal, it terminates after it executes all of the scripts whose symbolic links begin with K.
The administrator can change the names of symbolic links in /etc/rc2.d to do the following:
# filename: /etc/init.d/cron
# function: to start/stop the cron daemon
# first get generic functions
. /etc/init.d/funcs
# set the PATH properly to find the appropriate utils
PATH=/bin:/usr/contrib/bin:/usr/contrib
# now either 'start' or 'stop' the service - depends on the 1st argument
#
case $1 in
start)
# start the cron daemon
/usr/sbin/cron
[ $? = 0 ] && echo "cron started"
;;
stop)
# stop all instances of the cron daemon
#
killall cron
[ $? = 0 ] && echo "cron stopped"
;;
esac
exit 0