depinit - manual page for depinit (depinit) version 0.1.4
SYNOPSIS
depinit
[OPTION...]
DESCRIPTION
Start and stop services.
-d, --config-dir=DIR
Alternate configuration directory (default is
/etc/depinit)
-s, --syslog=PRIORITY
Messages sent to syslog. PRIORITY is one of
emergency, alert, critical, error, warning,
notice, warning, info, or debug.
-S, --no-syslog
Messages not sent to syslog (default if pid is not
1)
-e, --stderror=PRIORITY
Messages sent to stderr
-E, --no-stderror
Messages not sent to stderr (default if pid is 1)
-f, --file=FILE
File for stderr (default is /dev/console)
-?, --help
Give this help list
--usage
Give a short usage message
-V, --version
Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
depinit is a program for managing services, some of which can be provided by
daemons. Services can be started at boot time, or by an explicit command from
depctl. They can be stopped for shutdown and by an explicit command. Daemons
are automatically recreated if they die. Where possible the work is done in
parallel, limited by dependencies given in a configuration directory tree.
Depinit can be started as the init process (process id 1) or as an ordinary
process. Some of the defaults and the shutdown procedure change if depinit is
not process 1. As an ordinary process, depinit shuts down by killing any child
processes that it did not start, then it stops any process it did start. If
depinit is process 1, it then umounts everything except /dev and /proc.
Anything that cannot be unmounted is remounted read only. Loopback devices used
for mounts are detached, then the computer is switched off, halted, or rebooted
as required.
When started as process 1, depinit tells the kernel to send it the keyboard
signal, closes all file-decriptors, connects stderr to DEFAULT_ERROR_FILE,
catches SIGSEGV, and uses syslog facility daemon, (instead of user). Orphanned
processes are given parent process id 1, so depinit only does a proper job of
killing orphanned process for shutdown when it is process 1.
If
depinit_conf
is set, it overrides the default configuartion directory
/etc/depinit.
It does not override the command line.
depinit_stderr
If
depinit_stderr
is set, it overrides the default stderr file
/dev/console.
It does not override the command line.
FILES
/proc/sys/kernel/ctrl-alt-del
If this is set to '1', the kernel sends
SIGINT
to init when the
Boot
key is pressed.
The default value is '0'.
<configuration directory>/*/
One directory per service to manage.
<configuration directory>/<this_*>/depend
List of services, one per line that must have started before
this service can start. Also if
depinit
is explicitly told to
stop any service in this list, it will stop this service first.
<configuration directory>/<this_daemon>/daemon
Script to start a daemon.
If the script terminates,
depinit
restarts it.
Most daemons will fork off a process to provide the service,
and return.
Many will not do this if you use the correct options.
You must find these options to use the daemon with
depinit.
depinit
assumes a daemon has started
if it runs for a certain amount of time.
depinit
stops daemons with
SIGTERM
if they do not ignore that signal, otherwise
SIGHUP
if they have a contolling terminal, and do not ignore
SIGHUP.
If that is no good, depinit will use SIGINT (if it is not ignored).
If none of the above are chosen, or if the daemon did not die promptly,
depinit uses
SIGKILL.
This choice of signals is also used for killing orphanned processes
for shutdown.
<configuration directory>/<this_daemon>/dest
Like
'daemon', but stdin
is a pipe from another daemon.
<configuration directory>/<this_daemon>/filter
The logical combination of a dest and a source.
<configuration directory>/<this_daemon>/source
Like
'daemon', but stdout and stderr
are a pipe to another daemon (given in
depend).
If more than one daemon is mentioned in depend,
a separate pipe is opened for each,
starting at file descriptor 1.
<configuration directory>/<this_service>/start
Start script for a service.
Service is assumed to be started if
this script terminates with a result of 0.
If the service takes too long to start
while depinit is shutting down,
the service will receive
SIGTERM,
and if it does not die promptly,
SIGKILL.
If there is no
'daemon', 'source', 'dest', 'filter' or 'start' file,
depinit
assumes that a service has started if all its dependencies have started.
<configuration directory>/<this_service>/stop
If a service was started with a start script, or no script at all,
depinit
will use the
stop
script to stop it. If
depinit
is shutting down, and the
stop
script takes too long to complete,
the process for the
stop
script will receive
SIGTERM.
If it still takes too long,
it will receive
SIGKILL.
If
depinit
does not find a
stop
script, it assumes no action is required to stop the service.
<configuration directory>/default/
Default service to start when
depinit
is started.
<configuration directory>/exec
If depinit crashes, it execs this file.
Bare in mind that
stdin, stdout, stderr,
and the signal masks will not be set up properly.
<configuration directory>/fifo /dev/initctl
This fifo is used by
depctl(8)
to communicate with
depinit.
If
depinit
is process 1, it uses
/dev/initctl.
Otherwise it uses
<configurationdirectory>/fifo.
depinit
will create it if it does not exits,
and if the filesystem is mounted rw.
<configuration directory>/sig_*/
Service to start when
depinit
receives the corresponding signal.
/etc/depinit/
Default configuration directory.
/dev/console/
Default file for stderr when depinit started as process 1.
If depinit is not process 1, stderr is not changed.
SIGNALS
SIGHUP
Re-read dependencies.
SIGINT
Start
'sig_int'.
The kernel can be configured send
SIGINT
to init
when you press the
Boot
key.
The
Boot
key is normally <ctrl><alt><delete>,
but can be changed with
loadkeys(1).
SIGIO
Tells
depinit
to read
'<configuration directory>/fifo'.
or
'/dev/initctl'.
This is how
depctl(8)
communicates with
depinit.
SIGKILL
If depinit is process 1, start
'default'.
if depinit is not process 1, this signal cannot be caught
and depinit exits without shutting down the services.
SIGQUIT
Start
'sig_quit'.
The kernel will send
SIGQUIT
to the init process each time you press the
KeyboardSignal
key. If you want
'sig_quit'
to be run each time, make
sig_quit/start
end with "exec /sbin/depctl -k sig_quit".
SIGSEGV
If depinit is process 1, and it receives SIGSEGV, it logs a backtrace and execs
<configurationdirectory>/exec.
SIGTSTP
Toggles depinit's ability to start services and
daemons.
Each of these starts the corresponding service eg
SIGUSR1
starts
'sig_usr1'.
THANKS TO
The idea for this program came from simpleinit by Peter Orbaek, Werner
Almesberger, Richard Gooch and Matthias Benkmann. Thanks also Dr D. J.
Bernstein. His software is like lego for the internet, just as much fun
to play with, and makes this program usable.
AUTHOR
Written by Richard Lightman
Copyright 2002 Richard Lightman
This is free software; May be used and distributed under Version 2 of the GNU
public license see the source for copying conditions. There is NO warranty;
not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.