SINUX distribution 2.2 README file for /etc/init.d directory This file is Copyright (C) Pavel Troller ---------------------------------------------------------- Once I browsed the init(8) man page, I found that there should be a file, called README, in the /etc/init.d directory. I looked there, didn't find any, and because I'm considering myself as the SINUX integrator, I realised to write it. So, now You are reading it. ------------------------------------------------------------------------------- /etc/init.d conventions for the SINUX distribution, version 2.2 1. Contents of the /etc/init.d directory This directory is intended for containing: - This README file (most important) - Main daemons and services manipulating script, `daemons' - The above script configuration file, `daemon.config' - Other scripts for starting and stopping various system services and services. It doesn't contain any subdirectories. 2. The `daemons' script Its name may be interpreted as an abbreviation for `daemon script' - it is a combo of bash and awk and its task is to perform starting and stopping of various system daemons and services. This script is called by every runlevel change (including boot and changes to RL 0 and 6) directly by init, because init is instructed to do so by the /etc/inittab file. It is called with the `update' option, which means that it will stop the services and daemons which are not to be in use in the new runlevel and and start the ones which are to be used/running. BTW, another options of the `daemons' script are `start' and `stop', which perform the requested action only. However, this feature is not used by the system automatically. 3. The `daemon.config' file This file is read by the `daemons' script as its main (and only) configuration file. It contains lines which describe how to start and stop various system daemons and services. One typical line of this file may look as follows: 2345 D sendmail /usr/sbin/sendmail -bd -q15m ; /usr/bin/sleep 1 Every line contains fields separated by blanks or tabs. Their meaning is as follows: Field 1: List of runlevels. This list contains numbers of all the runlevels for which the particular service or daemon should be used. The numbers may be placed in any order, but for the readability and convenience, growing order is preferred. If there is a runlevel change which ends in one of listed runlevels, while the previous runlevel was not in the list, action will be performed to start the daemon or service. Reversely, if the new level is not listed while the old was, action to stop the daemon or service will take place. In any of two remaining cases, no action is performed. When stopping, the file is scanned in reverse order. When starting, it is scanned in direct order. That means, that lines contained later in the file will cause later start but former stop of the daemon/service. This feature helps to solve various dependencies of services or daemons. Field 2: Daemon/Service selector This field can currently contain 2 different letters (in both upper and lower case): - Letter "S" means that it is a service. - Letter "D" means that it is a daemon. This selects, how the entry is processed during starting or stopping. Daemons are processed by calling the command line (fields 4 up) to start the daemon and by calling `killal ', where is taken from field 3, to stop it. Services are processed by executing the command (field 4 only) with the `start' option to start the service and by executing it with the `stop' option to stop it. Field 3: Daemon/Service name For daemons, this field is used as a parameter for the `killall' command to kill the daemon. For both daemons and services, it is used for displaying on the console to inform the user which daemons/services are currently processed. Field 4 and up: For daemons, these fields form the command line. It may contain more than one command (see the example line) but currently there is a limit of maximally 12 blank separated words. When the line starts with the `#' symbol, it is ignored as a comment. It may also help to easily `deselect' a line from processing temporarily. 4. Other scripts in /etc/init.d In the /etc/init.d directory, there are also other scripts used for starting and stopping various system services and packages. Especially, there is a script named `boot', which is executed at the boot time by init. This script doesn't have any parameters and shouldn't be invoked manually except special cases. There are also other scripts, as: - netconfig - contains basic network configuration (loopback and ethernet interfaces and routing - pcmcia - for starting and stopping the PCMCIA package (for notebooks) - knfsd - for starting the NFS services - reboot, halt, dosreboot - for performing system shutdown - also called by `daemons' - local - for performing any special local setup (setting a console, font, video mode, keymap etc...) The system administrator may add other scripts for starting and stopping other system services. These scripts should accept options `start' and `stop', which are automatically supplied by the `daemons' script. Of course, to activate the script, there must be also an appropriate entry in the `daemon.config' file.