8.9 KiB
Configuration
Table of Contents
/etc/finit.conf
Contrary to most other script based init alternatives (SysV init,
upstart, systemd, OpenRC, etc.) Finit relies on its main
configuration file /etc/finit.conf and /etc/finit.d/.
The command line arguments given in /etc/finit.conf to each service
provide a default. A plugin can be used to register a callback to a
service and then modify the behavior to suit the current runlevel and
system configuration.
For instance, before starting a heavily resource intensive service like IPsec or OpenVPN, a callback can check if the outbound interface is up and has an IP address, or just check if the service is disabled — much like what a SysV init start script usually does.
Syntax:
-
check <DEV>
Run fsck on a file system before mounting it -
module <MODULE>
Load a kernel module, with optional arguments -
network <PATH>
Script or program to bring up networking, with optional arguments -
rlimit <hard|soft> RESOURCE <LIMIT|infinity>
Modify the specified resource's hard or soft limit to be the specifed limit.RESOURCEis a lower-case string matching the constants insetrlimit(2)with theRLIMIT_prefix removed. E.g. to selectRLIMIT_CPU,RESOURCEwould becpu.LIMITis an integer whose unit depends on the resource being modified, seesetrlimit(2)for more information. The special limitinfinitymeans the there should be no limit on the resource, i.e.RLIM_INFINITYis passed tosetrlimit(2).
# No process is allowed more than 8MB of address space
rlimit hard as 8388608
# Core dumps may be arbitrarily large
rlimit soft core infinity
-
runlevel <N>
N is the runlevel number 1-9, where 6 is reserved for reboot.
Default is 2. -
run [LVLS] <COND> /path/to/cmd ARGS -- Optional description
One-shot command to run in sequence when entering a runlevel, with optional arguments and description. This command is guaranteed to be completed before running the next command. -
task [LVLS] <COND> /path/to/cmd ARGS -- Optional description
One-shot like 'run', but starts in parallel with the next command -
service [LVLS] <COND> /path/to/daemon ARGS -- Optional description
Service, or daemon, to be monitored and automatically restarted if it exits prematurely. Please note that you often need to provide a--foregroundor--no-backgroundargument to most daemons to prevent them from forking off a sub-process in the background.
service [2345] <svc/sbin/zebra> /sbin/ospfd -- OSPF daemon
For a detailed description of conditions, and how to debug them, see the Finit Conditions document.
inetd service/proto[@iflist] <wait|nowait> [LVLS] /path/to/daemon args
Launch a daemon when a client initiates a connection on an Internet port. Available services are listed in the UNIX/etc/servicesfile. Finit can filter access to from a list of interfaces,@iflist, per inetd service as well as listen to custom ports.
inetd ftp/tcp nowait @root /usr/sbin/uftpd -i -f
inetd tftp/udp wait @root /usr/sbin/uftpd -i -t
The following example listens to port 2323 for telnet connections and
only allows clients connecting from eth0:
inetd 2323/tcp@eth0 nowait [2345] /sbin/telnetd -i -F
The interface list, @iflist, is of the format @iface,!iface,iface,
where a single ! means to deny access. Notice how interfaces are
comma separated with no spaces.
The inetd directive can also have -- Optional Description, only
Finit does not output this text on the console when launching inetd
services. Instead this text is sent to syslog and also shown by the
initctl tool. More on inetd below.
-
runparts <DIR>
Call run-parts(8) onDIRto run start scripts. All executable files, or scripts, in the directory are called, in alphabetic order.It can be beneficial to use
S01name,S02othername, etc. if there is a dependency order between the scripts. Symlinks to existing daemons can talso be used, but make sure they daemonize by default.As the optional
/etc/rc.localshell script, make sure that all your services and programs either terminate or start in the background or you will block Finit. -
include <CONF>
Include another configuration file. Absolute path required. -
tty [LVLS] <DEV | /path/to/cmd [args]>
Start a getty on the given TTY device DEV, in the given runlevels. If no tty setting is given infinit.conf, or if/bin/shis given as argument instead of a device path, a single shell is started on the default console. Useful for really bare-bones systems.It is also possible to supply the full command line, with arguments, to your getty. In this case finit will simply use that command.
See
finit.hfor the#define GETTYthat is called, along with the default baud rate.Note: BusyBox getty, used when Finit is built for embedded systems, can take a
DEVwith or without/dev/prefix. Make sure to call the configure script with--enable-embeddedif this is what you want. -
console <DEV | /path/to/cmd [args]
Some embedded systems have a dedicated serial console/service port. This command tells finit to not start getty directly, since there may not be anyone there. To save RAM and CPU finit instead displays a friendly message and waits for the user to activate the console with a key press before starting getty. Finit also does some other magic and changes the process name to "console".Like the
ttycommand, theconsolecommand can also be used to simply start a UNIX shell, e.g./bin/sh.
When running make install no default /etc/finit.conf will
be installed since system requirements differ too much. Try out the
Debian 6.0 example /usr/share/doc/finit/finit.conf configuration that
is capable of service monitoring SSH, sysklogd, gdm and a console getty!
Every run, task, service, or inetd can also list the privileges
the /path/to/cmd should be executed with. Simply prefix the path with
[@USR[:GRP]] like this:
run [2345] @joe:users /usr/bin/logger "Hello world"
For multiple instances of the same command, e.g. a DHCP client or
multiple web servers, add :ID somewhere between the run, task,
service keyword and the command, like this:
service :1 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
service :2 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
Without the :ID to the service the latter will overwrite the former
and only the old web server would be started and supervised.
The run, task, service, or inetd stanzas also allow the keyword
log to redirect stderr and stdout of the application to syslog,
using logger.
/etc/finit.d
Finit supports changes to the overall system configuration at runtime.
For this purpose the (configurable) directory /etc/finit.d is used.
Here you can put configuration file snippets, one per service if you
like, which are all sourced automatically by finit at boot when loading
the static configuration from /etc/finit.conf. This is the default
behavior, so no include directives are necessary.
To add a new service, simply drop a .conf file in /etc/finit.d and
run initctl reload. (It is also possible to SIGHUP to PID 1, or
call finit q, but that has been deprecated with the initctl tool).
Any service read from this directory is flagged as a dynamic service, so
changes to or removal of /etc/finit.d/*.conf files, is detected.
On initctl reload the following is checked for all services:
- If a service's
.conffile has been removed, or its conditions are no longer satisifed, the service is stopped. - If the file is modified, or a service it depends on has been reloaded, the service is reloaded (stopped and started).
- If a new service is added it is automatically started — respecting runlevels and return values from any callbacks.
For more info on the different states of a service, see the separate document Finit Services.
The /etc/finit.d directory was previously the default Finit runparts
directory. Finit no longer has a default runparts, so make sure to
update your setup, or the finit configuration, accordingly.
Note: Configurations read from /etc/finit.d are read after
initial bootstrap, runlevel S(1). Hence, bootstrap services must be
in /etc/finit.conf!