Sortix main manual
This manual documents Sortix main. You can instead view this document in the latest official manual.
NAME
init — system initialization configurationDESCRIPTION
init(8) starts each daemon(7) (system background process) according to the daemon's configuration file, which specifies the daemon's dependencies and how to run the daemon.DAEMONS
The default daemon should require exactly one top level daemon with exit-code and nothing else.- multi-user
- Starts the operating system in the multi-user mode. It starts the login foreground daemon that provides a login screen and exits with login's exit code when login exits. This is a secure operating system mode where only authorized users have access. It depends on the base and local daemons.
- no-user
- Starts the operating system in the no-user mode. This is a secure operating system mode where no user is granted access. Additional daemons can be started by configuring the local daemon. It depends on the base and local daemons. The dependency on local is marked exit-code, letting the system administrator fully control the default daemon's exit code and when the system completes.
- single-user
- Starts the operating system in the single user mode. This foreground daemon starts the sh program that directly provides a root shell and exits with the shell's exit code when the shell exits. This operating system mode is insecure because it boots straight to root access without a password. It depends on the base and local daemons.
- sysinstall
- Starts the operating system installer. This foreground daemon starts the sysinstall program that provides the operating system installer and exits with the installer's exit code when the installer exits. This operating system mode is insecure because it boots straight to root access without a password. It depends on the base and local daemons.
- sysupgrade
- Starts the operating system upgrader. This foreground daemon starts the sysupgrade program that provides the operating system upgrader and exits with the upgrader's exit code when the upgrader exits. This operating system mode is insecure because it boots straight to root access without a password. It depends on the base and local daemons.
- base
- Virtual daemon that depends on the core operating system daemons. It depends on the network and time daemons.
- dhclient
- Daemon that starts dhclient(8) on each network interface and becomes ready when each network interface has been attempted configured.
- local
- Virtual daemon that starts daemons pertinent to the local system. The system provides a default implementation that does nothing. The system administrator is meant to override the daemon in /etc/init/local by depending on daemons outside of the base system that should run on the local system.
- network
- Virtual daemon that becomes ready when an attempt has been made to establish network connectivity. It depends on the dhclient deamon. Daemons can depend on this daemon if they need the network to have been established before they start.
- time
- Virtual daemon that becomes ready when the current date and time has been established. The system provides a default implementation that does nothing, as the base system does not contain a daemon that obtains the current date and time. The system administrator is meant to override the daemon in /etc/init/time by depending on a daemon that obtains the current date and time and sets the system time. Daemons can depend on this daemon if they need the current date and time to have been established before they start.
FORMAT
Daemon configuration files are processed line by line. Each line specifies a property of the daemon. Lines are tokenized like shell commands on white space with support for single qoutes, double quotes, and backslash escape sequences (\\, \', \", \a, \b, \e, \f, \n, \r, \t, \v). The # character starts a comment and the rest of the line is ignored.- cd directory
- The working directory to run the deamon inside. (Default is /)
- exec command
-
The command line that starts the daemon. The daemon becomes ready when it writes a newline to the file descriptor mentioned in the READYFD environment variable as described in daemon(7).
- exit-code-meaning [default | poweroff-reboot]
-
This property specifies how to interpret the exit code.
- furthermore
-
The current daemon configuration file extends an existing daemon that is defined in a configuration file by the same name later in the search path. The later configuration file is included into the current configuration file. This statement can only be used once per configuration file, any subsequent uses are silently ignored, but it can be used recursively. Customizing an existing daemon should be done by adding a new daemon file earlier in the search path that starts with the furthermore statement, followed by additional configuration.
- log-control-messages [false | true]
-
Includes control messages such as the start and stop of the daemon and loss of log data. Control messages are inserted as entries from the daemon init.
- log-file-mode octal
-
Sets the log file permissions to the octal mode with chmod(2).
- log-format format
-
Selects the format of the log:
- none
- The log is exactly as written by the daemon with no additional formatting.
- seconds
-
"YYYY-dd-mm HH:MM:SS +0000: "
- nanoseconds
-
"YYYY-dd-mm HH:MM:SS.nnnnnnnnn +0000: "
- basic
-
"YYYY-dd-mm HH:MM:SS.nnnnnnnnn +0000 daemon: "
- full
-
"YYYY-dd-mm HH:MM:SS.nnnnnnnnn +0000 hostname daemon: "
- syslog
-
"<ppp>1 YYYY-dd-mmTHH:MM:SS.uuuuuuZ hostname daemon pid - - "
- log-line-size line-size
-
When using the rotate log method, log files are cut at newlines if the lines don't exceed line-size bytes.
- log-method [none | append | rotate]
-
Selects the method for logging:
- none
- Disable logging.
- append
-
Always append the log data to the log file without any rotation. For instance, exampled.log will contain all the log entries ever produced by the exampled daemon.
- rotate
-
Append lines to the log file until it becomes too large, in which case the daemon's logs are rotated.
- log-rotate-on-start [false | true]
-
When starting the daemon, rotate the logs (when using the rotate log method) or empty the log (when using the append log method), such that the daemon starts out with a new log.
- log-size size
-
When using the rotate log method, keep each log file below size bytes.
- need tty
- Specifies that the daemon is not a background daemon, but instead is the foreground daemon controlling the terminal in the tty property. The daemon is made a process group leader. The terminal's foreground process group is set to that of the daemon. The terminal is enabled by setting CREAD. The daemon is not logged, and the standard input, output, and error are instead connected to the terminal Foreground daemons are automatically considered ready and don't participate in the READYFD daemon readiness protocol. Upon exit, the original terminal settings are restored and init(8) reclaims ownership of the terminal.
- per if
- Specifies that an instance of the daemon should run for each network interface. The daemon becomes a virtual daemon that depends on on the instantiated daemons for each network interface. The name of each instantiated daemon is the name of the virtual daemon plus ‘.’ plus the name of the network interface (e.g. exampled running on the loopback interface lo0 would be example.lo0). The name of the network interface is appended as a command line argument on the command line of each instantiated daemon. It is not possible to depend on the instantiated daemons.
- require dependency [flag ...]
-
When the daemon is needed, start the dependency first. The daemon starts when all its dependencies have become ready or have finished. Dependencies are started in parallel whenever possible. If the daemon hasn't started yet, and any non-optional dependency finishes unsuccessfully, then the daemon doesn't start and instead directly finishes unsuccessfully. If the daemon has started, it is the daemon's responsibility to detect failures in its dependencies.
- exit-code
- If the daemon is a virtual daemon, then the daemon's exit code is that of the specific dependency rather than whether all dependencies succeeded. The daemon exits as soon as the dependency exits, rather than waiting for all dependencies to exit. The exit-code-meaning field is set to that of the dependency. exit-code can at most be used on a single dependency for a daemon.
- no-await
- Don't wait for the dependency to become ready before starting this daemon. This flag is meant for dependencies that the daemon can make use of, but isn't essential to the daemon itself becoming ready. It shouldn't be used if the daemon polls for the dependency to come online, as it is more efficient to only start the daemon once the dependency is ready.
- optional
- Start the daemon even if the dependency fails. The dependency is assumed to exist and a warning occurs if it doesn't exist.
- unset property
- Reset the given property to its default value.
- tty device
-
If the daemon is a foreground daemon (need tty is set), then connect the daemon to the terminal named device.
ENVIRONMENT
Daemons inherit their environment from init(8) with this additional environment:- READYFD
- Daemons signal they are ready by writing a newline to the file descriptor mentioned in the READYFD environment variable as described in daemon(7).
FILES
- /etc/init/
- Daemon configuration for the local system (first in search path).
- /etc/init/default
- The configuration file for the default daemon.
- /etc/init/local
- The configuration file for the local daemon which depends on the installation's local daemons.
- /share/init/
- Default daemon configuration provided by the operating system (second in search path).
- /var/log/
- Daemon log files.
EXAMPLES
Configuring a daemon to start on boot
The local system can be configured to start the exampled daemon by creating /etc/init/local with the following contents:require exampled optional
Disable network auto-configuration (DHCP)
The network daemon depends by default on dhclient, which does DHCP configuration of the network. This dependency can be removed by creating /etc/init/network with the following contents:furthermore unset require dhclient
Creating a new daemon
The exampled daemon, which depends on the food, bard, and quxd daemons and whose program file is called exampled, can then be configured by creating /etc/init/exampled with the following contents:require food require bard require quxd exec exampled
Changing the log format
The default log format of daemons and init(8)'s own can be set by setting the properties in /etc/init/default. A few examples:log-format full log-method append
log-control-messages false log-format none log-method rotate log-rotate-on-start true
Configuring a multi-user system
The system can be configured to boot into multi-user mode by creating /etc/init/default with the following contents:require multi-user exit-code
Configuring an unattended system
A fully unattended system that only starts the base system and the exampled daemon, shutting down when the exampled daemon finishes, can be done by first creating /etc/init/default with the following contents:require no-user exit-code
require exampled exit-code