<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="system-control">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>system-control</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">administrator commands</refmiscinfo>
<refmiscinfo class="source">nosh</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv>
<refname>system-control</refname>
<refname>systemctl</refname>
<refpurpose>process system control jobs, sending commands to the system manager and service manager</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req"><replaceable>command</replaceable></arg>
<arg><replaceable>arguments or options</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>systemctl</command>
<arg choice="req"><replaceable>command</replaceable></arg>
<arg><replaceable>arguments or options</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>Description</title>

<para>
<command>system-control</command> takes a subcommand as <replaceable>command</replaceable> that instructs it on what to do.
</para>

<para>
For limited systemd compatibility, it is also available as <command>systemctl</command>.
Not all subcommands are supported, nor is placing subcommand options before the <replaceable>command</replaceable>.
</para>

<note>
The compatibility shims for upstart, SunOS, and others are provided by <citerefentry><refentrytitle>telinit</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
<command>system-control</command> provides no upstart or SunOS compatibility itself, and its various subcommands differ in meaning from most of the subcommands for upstart <citerefentry><refentrytitle>initctl</refentrytitle><manvolnum>8</manvolnum></citerefentry> and SunOS <citerefentry><refentrytitle>svcadm</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</note>

<para>
It operates in one of two modes, controlled by the <arg choice="req">--user</arg> command line option:
</para>

<itemizedlist>
<listitem>
<para>
In "system" mode it operates on system-wide state and services.
It potentially communicates with a System Manager process, which must be process #1 and which it expects to recognize the same signals as <citerefentry><refentrytitle>system-manager</refentrytitle><manvolnum>1</manvolnum></citerefentry> does.
It potentially communicates with a Service Manager process, such as <citerefentry><refentrytitle>service-manager</refentrytitle><manvolnum>1</manvolnum></citerefentry> via a local domain socket at <filename>/run/service-manager/control</filename> and via the control/status API of the individual services.
</para>
</listitem>
<listitem>
<para>
In "user" mode it operates on per-user state and services.
It potentially communicates with a Session Manager process, which again it expects to recognize the same signals as <citerefentry><refentrytitle>per-user-manager</refentrytitle><manvolnum>1</manvolnum></citerefentry> does.
It potentially communicates with a Service Manager process, such as <citerefentry><refentrytitle>service-manager</refentrytitle><manvolnum>1</manvolnum></citerefentry> via a local domain socket at <filename>/run/user/<replaceable>$USER</replaceable>/service-manager/control</filename> and via the control/status API of the individual services.
</para>
</listitem>
</itemizedlist>

<para>
Services are defined by directories known as bundle directories.
What they contain and where and how they are located is documented in <citerefentry><refentrytitle>service-bundle</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>

</refsection>

<refsection id="SUBCOMMANDS" xreflabel="SUBCOMMANDS">
<title>Subcommands</title>

<refsection id="INFORMATION" xreflabel="INFORMATION">
<title>System information subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">version</arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
For compatibility with uses of <command>initctl</command>, the <command>version</command> subcommand displays the (compiled-in) version of the toolset.
It does not contain the string "upstart".
</para>

</refsection>
<refsection id="SYSTEMCONTROL" xreflabel="SYSTEMCONTROL">
<title>System control subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">reboot</arg>
<group choice='opt'><arg choice="plain">-f</arg><arg choice="plain">--force</arg></group>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">halt</arg>
<group choice='opt'><arg choice="plain">-f</arg><arg choice="plain">--force</arg></group>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">powercycle</arg>
<group choice='opt'><arg choice="plain">-f</arg><arg choice="plain">--force</arg></group>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">poweroff</arg>
<group choice='opt'><arg choice="plain">-f</arg><arg choice="plain">--force</arg></group>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">emergency</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">rescue</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">normal</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">init</arg>
<arg choice="opt">--user</arg>
<group choice="opt">
<arg choice="plain">-o</arg>
<arg choice="plain">--update</arg>
</group>
<group choice="opt">
<arg choice="plain">-s</arg>
<arg choice="plain">--single</arg>
</group>
<group choice="opt">
<arg choice="plain">-b</arg>
<arg choice="plain">--emergency</arg>
</group>
<arg choice="opt">-a</arg>
<arg choice="opt">-f</arg>
<arg choice="opt">-z <replaceable>string</replaceable></arg>
<arg repeat="rep"><replaceable>runlevel(s)</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
Those subcommands communicate with the system manager to change system state.
<command>system-control</command> sends a signal to process #1 using the <citerefentry><refentrytitle>kill</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call.
It will fail if it does not have the necessary privileges for sending a signal to that process.
</para>

<table>
<title>The signals for each subcommand:</title>
<thead>
<tr><th>command</th><th>signal on FreeBSD and NetBSD</th><th>signal on Linux</th><th>signal on OpenBSD</th></tr>
</thead>
<tbody>
<tr><td><command>halt</command></td><td><code>SIGUSR1</code></td><td><code>SIGRTMIN + 3</code></td><td>unsupported</td></tr>
<tr><td><command>halt</command> <arg choice='plain'>-f</arg></td><td><code>SIGRTMIN + 13</code></td><td><code>SIGRTMIN + 13</code></td><td>unsupported</td></tr>
<tr><td><command>poweroff</command></td><td><code>SIGUSR2</code></td><td><code>SIGRTMIN + 4</code></td><td>unsupported</td></tr>
<tr><td><command>poweroff</command> <arg choice='plain'>-f</arg></td><td><code>SIGRTMIN + 14</code></td><td><code>SIGRTMIN + 14</code></td><td>unsupported</td></tr>
<tr><td><command>reboot</command></td><td><code>SIGINT</code></td><td><code>SIGRTMIN + 5</code></td><td>SIGINT</td></tr>
<tr><td><command>reboot</command> <arg choice='plain'>-f</arg></td><td><code>SIGRTMIN + 15</code></td><td><code>SIGRTMIN + 15</code></td><td>SIGTSTP</td></tr>
<tr><td><command>powercycle</command></td><td><code>SIGWINCH</code></td><td><code>SIGRTMIN + 7</code></td><td>unsupported</td></tr>
<tr><td><command>powercycle</command> <arg choice='plain'>-f</arg></td><td><code>SIGRTMIN + 17</code></td><td><code>SIGRTMIN + 17</code></td><td>unsupported</td></tr>
<tr><td><command>emergency</command></td><td><code>SIGRTMIN + 2</code></td><td><code>SIGRTMIN + 2</code></td><td>unsupported</td></tr>
<tr><td><command>rescue</command></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 1</code></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 1</code></td><td>unsupported</td></tr>
<tr><td><command>normal</command></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 0</code></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 0</code></td><td>unsupported</td></tr>
<tr><td><command>init</command> <group choice='opt'><arg choice='plain'>2</arg><arg choice='plain'>3</arg><arg choice='plain'>4</arg><arg choice='plain'>5</arg><arg choice='plain'>m</arg><arg choice='plain'>auto</arg></group></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 0</code></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 0</code></td><td>unsupported</td></tr>
<tr><td rowspan='2'><command>init</command> <group choice='plain'><arg choice='plain'>1</arg><arg choice='plain'>S</arg><arg choice='plain'>s</arg><arg choice='plain'>single</arg></group></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 1</code></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 1</code></td><td>unsupported</td></tr>
<tr><td><command>init</command> <group choice='plain'><arg choice='plain'>-s</arg></group></td><td><code>SIGRTMIN + 2</code></td><td><code>SIGRTMIN + 10</code> then <code>SIGRTMIN + 1</code></td><td>unsupported</td></tr>
<tr><td><command>init</command> <group choice='plain'><arg choice='plain'>-b</arg></group></td><td>unsupported</td><td><code>SIGRTMIN + 2</code></td><td>unsupported</td></tr>
<tr><td><command>init</command> <group choice='plain'><arg choice='plain'>b</arg><arg choice='plain'>emergency</arg></group></td><td><code>SIGRTMIN + 2</code></td><td><code>SIGRTMIN + 2</code></td><td>unsupported</td></tr>
<tr><td><command>init</command> <group choice='plain'><arg choice='plain'>H</arg><arg choice='plain'>h</arg></group></td><td>SIGUSR1</td><td><code>SIGRTMIN + 3</code></td><td><code>SIGUSR1</code></td></tr>
<tr><td><command>init</command> <group choice='plain'><arg choice='plain'>C</arg><arg choice='plain'>c</arg></group></td><td><code>SIGWINCH</code></td><td><code>SIGRTMIN + 7</code></td><td>unsupported</td></tr>
<tr><td><command>init</command> <arg choice='plain'>0</arg></td><td><code>SIGUSR2</code></td><td><code>SIGRTMIN + 4</code></td><td>SIGUSR2</td></tr>
<tr><td><command>init</command> <arg choice='plain'>6</arg></td><td><code>SIGINT</code></td><td><code>SIGRTMIN + 5</code></td><td>SIGINT</td></tr>
</tbody>
</table>

<note>
OpenBSD lacks the ability to send real-time signals.
</note>

<para>
Exactly how the system power cycles, powers off, halts, reboots, switches to normal, emergency, or rescue modes, and so forth is entirely up to whatever is running as process #1, which is expected to be in charge of system state.
These subcommands do nothing except send the signals to command the system manager.
They do not directly enact any system state change themselves.
In part this is because that would open up the possibility of the service manager killing the process that was (partway through) enacting the state changes, if a state change happened to affect the service running the <command>system-control</command> command.
</para>

<para>
The <arg>--force</arg> command line argument is used within the various targets and is intended to cause the system manager to proceed directly to the finalization action.
</para>

<para>
The <command>init</command> subcommand is spawned by <citerefentry><refentrytitle>system-manager</refentrytitle><manvolnum>8</manvolnum></citerefentry> and <citerefentry><refentrytitle>per-user-manager</refentrytitle><manvolnum>8</manvolnum></citerefentry> as their initial action.
They pass it the command line arguments that they themselves were invoked with.
As such, its command line syntax is modelled on what boot loaders and kernels tend to supply to process #1, which is a largely undocumented and non-standardized mixture of old-style runlevels and options.
</para>

<para>
In normal and rescue modes it sends two signals to process #1, instituting a two-phase initialization sequence similar to the <code>FILESYSTEMS</code> milestone mechanism in BSD operating systems.
The first phase, the <code>sysinit</code> target, is expected to initialize as much of the system as necessary so that the second phase, the <code>normal</code> or <code>rescue</code> target, can find all service and target bundles, including those that are not on the root filesystem.
</para>

<caution>
There is no <arg choice="plain">q</arg> runlevel.
This is deliberate.
Its use case is running <command>telinit</command> <arg choice="plain">q</arg> after updating <filename>/etc/ttys</filename> or <filename>/etc/inittab</filename>.
Any script that is updating those files and then expecting the system manager to re-read them is not targetting the correct configuration mechanisms, and is in error.
<ulink url="http://jdebp.uk./FGA/inittab-is-history.html"><filename>/etc/inittab</filename> was obsolete as of AT&#x0026;T Unix System 5 Release 4</ulink>.
</caution>

<para>
LILO, the FreeBSD <citerefentry><refentrytitle>loader</refentrytitle><manvolnum>8</manvolnum></citerefentry>, GRUB, and others may cause <arg choice='plain'>-a</arg> or <arg choice='plain'>-f</arg> options to be passed.
Their meanings are non-standard, largely or even wholly undocumented, inconsistent across platforms and toolsets, considered obsolete in their original forms, and without application here.
The <arg choice='plain'>-z</arg> option is a dummy space-taker that is also used by such systems.
All three options are ignored.
The <arg choice='plain'>--update</arg> command line option is reserved for future use.
</para>

</refsection>
<refsection id="JOB" xreflabel="JOB">
<title>job subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<group choice='req'>
<arg choice="plain">start</arg>
<arg choice="plain">activate</arg>
</group>
<arg choice='opt'>--colour</arg>
<arg choice='opt'>--verbose</arg>
<arg choice='opt'>--pretend</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<group choice='req'>
<arg choice="plain">stop</arg>
<arg choice="plain">deactivate</arg>
</group>
<arg choice='opt'>--colour</arg>
<arg choice='opt'>--verbose</arg>
<arg choice='opt'>--pretend</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">isolate</arg>
<arg choice='opt'>--colour</arg>
<arg choice='opt'>--verbose</arg>
<arg choice='opt'>--pretend</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">reset</arg>
<arg choice='opt'>--colour</arg>
<arg choice='opt'>--verbose</arg>
<arg choice='opt'>--pretend</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
These subcommands process one or more jobs, sending messages to the service manager to start or to stop one or more services.
Jobs processing tries to ensure that service dependencies are correctly maintained and processed.
To control services directly and individually without regard for dependencies, use <citerefentry><refentrytitle>service-control</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para>

<para>
The <arg choice="plain">--verbose</arg> command line option causes information about actions taken and blocked/unblocked services to be written to standard error as jobs are processed.
If the standard error is a terminal, <command>system-control</command> uses whatever it can find via the <citerefentry><refentrytitle>TerminalCapabilities</refentrytitle><manvolnum>3</manvolnum></citerefentry> library to display various parts of the output in different colours, highlighting different events in different colours.
The <arg choice='plain'>--colour</arg> command line option tells it to do this unconditionally, even if its standard error is not a terminal.
The <arg choice='plain'>--pretend</arg> command line option tells it to only pretend that it is taking actions, and not actually take them.
</para>

<para>
The <command>reset</command> command is intended to be used by package installer programs.
It is translated into either <command>start</command> or <command>stop</command> according to whether the service is enabled or disabled; and can be thought of, if one likes, as "reset to however the service is configured to be at bootstrap".
This allows package installers to remain in blissful ignorance of whether a service should be started or stopped after installing the package for it.
Instead, the package installer simply executes the <command>preset</command> command and then the <command>reset</command> command and the service is started or stopped according to whatever the administrator has chosen.
</para>

<caution>
The <command>isolate</command> subcommand exists for compatibility, and is equivalent to <command>start</command>.
Avoid using it.
</caution>

<refsection id="JOBS" xreflabel="JOBS">
<title>Jobs and actions</title>

<para>
Jobs comprise a set of actions.
Each action is a ndividualstart or a stop command to the control API of a service/target as would be directly issued by <citerefentry><refentrytitle>service-control</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
Jobs are composed by starting with an action on a named service, and then following information in its service bundles to related services and targets, and in their service bundles in turn.
The service bundles also determine the order in which the actions are taken.
</para>

<para>
A start action simply requests that the service manager bring the service/target to the "running" state, if it isn't already there.
A stop action, however, is more complex.
Initially it requests that the service manager bring the service/target to the "stopped" state (if it isn't already there).
However, if that does not happen within 60 seconds, it requests that the service manager send the <code>SIGKILL</code> signal to the service/target.
</para>

</refsection>

</refsection>

<refsection id="AUTOBOOT" xreflabel="AUTOBOOT">
<title>service autoboot configuration subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">enable</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">disable</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">preset</arg>
<arg choice='opt'>--prefix <replaceable>prefix</replaceable></arg>
<arg choice='opt'>--no-system</arg>
<arg choice='opt'>--no-rcconf</arg>
<arg choice='opt'>--rcconf-file <replaceable>filename</replaceable></arg>
<arg choice='opt'>--ttys</arg>
<arg choice='opt'>--dry-run</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
These subcommands enable or disable one or more services or targets, so that they do or do not automatically start when one of the standard targets is started and automatically stop when the shutdown standard target is started.
</para>

<para>
Each service bundle specifies a (symbolically linked) list of target bundles in its <filename>wanted-by/</filename> directory.
Usually these will be the <filename>workstation</filename>, <filename>server</filename>, <filename>users</filename>, or <filename>multi-user</filename> standard targets.
For each bundle, enabling the service involves symbolically linking its bundle directory into the target bundle's <filename>wants/</filename> list, and disabling the service involves removing that link.
</para>

<para>
Each service bundle also specifies a (symbolically linked) list of target bundles in its <filename>stopped-by/</filename> directory.
Usually these will be the <filename>shutdown</filename> standard target.
For each bundle, enabling the service involves symbolically linking its bundle directory into the target bundle's <filename>conflicts/</filename> and <filename>after/</filename> lists, and disabling the service involves removing those links.
</para>

<para>
The <command>preset</command> command is intended to be used by package installer programs.
It is translated into either <command>enable</command> or <command>disable</command> according to a system/administrator-supplied preset flag (unless the <arg choice='plain'>--dry-run</arg> command line argument is used, causing it to take no actual action).
This allows package installers to remain in blissful ignorance of whether a service should be enabled or disabled after installing the package for it.
Instead, the package installer simply executes the <command>preset</command> command and the service is set to whatever enabled or disabled status the administrator has chosen.
</para>

<para>
The service/socket/target that is preset is <replaceable>prefix</replaceable><replaceable>name</replaceable>, with <replaceable>prefix</replaceable> specifiable via the <arg choice='plain'>--prefix</arg> command line argument.
</para>

<para>
Preset information can be taken from one of several sources:
</para>
<itemizedlist>
<listitem><para>
(unless the <arg choice="plain">--no-system</arg> command line option is set) systemd and system-manager preset information given in <filename>*.preset</filename> files.
There are different sets of files for per-user and system-wide service management.
</para>
<itemizedlist>
<listitem><para>
System-wide preset files are located in the following directories:
</para>
<orderedlist>
<listitem><para><filename>/usr/local/etc/system-control/presets/</filename></para></listitem>
<listitem><para><filename>/etc/system-control/presets/</filename></para></listitem>
<listitem><para><filename>/etc/systemd/system-preset/</filename></para></listitem>
<listitem><para><filename>/usr/local/lib/systemd/system-preset/</filename></para></listitem>
<listitem><para><filename>/usr/local/share/system-control/presets/</filename></para></listitem>
<listitem><para><filename>/usr/pkg/etc/system-control/presets/</filename></para></listitem>
<listitem><para><filename>/usr/share/system-control/presets/</filename></para></listitem>
<listitem><para><filename>/usr/lib/systemd/system-preset/</filename></para></listitem>
<listitem><para><filename>/lib/systemd/system-preset/</filename></para></listitem>
</orderedlist>
</listitem>
<listitem><para>
Per-user preset files are located in the following directories:
</para>
<orderedlist>
<listitem><para><filename>/usr/local/etc/system-control/user-presets/</filename></para></listitem>
<listitem><para><filename>/etc/system-control/user-presets/</filename></para></listitem>
<listitem><para><filename>/etc/systemd/user-preset/</filename></para></listitem>
<listitem><para><filename>/usr/local/lib/systemd/user-preset/</filename></para></listitem>
<listitem><para><filename><envar>$HOME</envar>/.config/system-control/presets/</filename></para></listitem>
<listitem><para><filename>/usr/local/share/system-control/user-presets/</filename></para></listitem>
<listitem><para><filename>/usr/pkg/etc/system-control/user-presets/</filename></para></listitem>
<listitem><para><filename>/usr/share/system-control/user-presets/</filename></para></listitem>
<listitem><para><filename>/usr/lib/systemd/user-preset/</filename></para></listitem>
<listitem><para><filename>/lib/systemd/user-preset/</filename></para></listitem>
</orderedlist>
</listitem>
</itemizedlist>
<para>
<ulink url="http://jdebp.uk./FGA/systemd-documentation-errata.html">Contrary to its doco, systemd has four places for system-wide/user-level preset files</ulink>, which form part of these lists.
In addition to those locations, <command>preset</command> looks in extra directories where systemd presets can be overridden by system-control-specific information; allowing a system administrator or package writer to preset things one way for systemd and another way for the <command>preset</command> command.
These extra directories follow the more conventional scheme of <filename>/etc</filename>, <filename>/usr/share</filename>, and <filename>/usr/pkg/etc</filename> for administrator-set, operating-system-set, and application-software-set stuff.
</para>
<para>
As with systemd, earlier preset directories override later ones; the contents of files with lexically earlier names override the contents of files with lexically later names; and the default state, in the absence of an explicit preset, is "enabled".
Directives are matched against <replaceable>prefix</replaceable><replaceable>name</replaceable>.
</para></listitem>
<listitem><para>
(unless the <arg choice="plain">--no-rcconf</arg> command line option is set) <citerefentry><refentrytitle>rc.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> preset information, specifically the <envar><replaceable>name</replaceable>_enable</envar> variable, interpreting the values <code>true</code>, <code>1</code>, <code>yes</code>, and <code>on</code> as enable, and any other values (including specifically <code>false</code>, <code>0</code>, <code>no</code>, and <code>off</code>) as disable.
<para>
</para>
By default in system-wide mode the <filename>/etc/defaults/rc.conf</filename>, <filename>/etc/rc.conf</filename>, and <filename>/etc/rc.conf.local</filename> files are used, but the <arg choice="plain">--rcconf-file</arg> command line option overrides that list with the single replacement file <replaceable>filename</replaceable>.
The default for per-user mode is the <filename><envar>$HOME</envar>/.config/rc.conf</filename> file.
</para>
<para>
The variable names are matched against just <replaceable>name</replaceable> to allow one to use a main service name as <replaceable>name</replaceable> and combine it with a log service template <replaceable>prefix</replaceable> such as <code>cyclog@</code> or <code>s6-multilog@</code>, on the grounds that traditional <filename>/etc/defaults/rc.conf</filename>, <filename>/etc/rc.conf</filename>, and <filename>/etc/rc.conf.local</filename> contents do not make explicit provision for separate logging services.
</para></listitem>
<listitem><para>
(if the <arg choice="plain">--ttys</arg> command line option is set) <filename>/etc/ttys</filename> preset information, specifically the <code>on</code> and <code>off</code> flags as enable and disable, respectively.
The <code>onifconsole</code> flag is also recognized and processed with reference to the currently active console device (on BSD systems only).
If <filename>/etc/ttys</filename> does not exist, as is usually the case on Linux operating systems, all TTYs default to preset disabled.
</para>
<para>
The terminal names are matched against just <replaceable>name</replaceable>.
This allows one to use an ordinary TTY device name as <replaceable>name</replaceable> and combine it with a "templatized" bundle name <replaceable>prefix</replaceable> such as <code>ttylogin@</code>, <code>getty@</code>, or <code>agetty@</code>.
</para></listitem>
<listitem><para>
(if the <arg choice="plain">--fstab</arg> command line option is set)
<filename>/etc/fstab</filename> preset information, specifically the <code>noauto</code> flag as disable.
</para>
<para>
The device and directory names are matched against just <replaceable>name</replaceable>, after unescaping it.
This allows one to use an ordinary device or directory name as <replaceable>name</replaceable> and combine it with a "templatized" bundle name <replaceable>prefix</replaceable> such as <code>mount@</code>, <code>fsck@</code>, <code>swap@</code>, or <code>dump@</code>.
This is designed in particular for use with service bundles generated by the <command>convert-fstab-services</command> subcommand.
</para></listitem>
</itemizedlist>

</refsection>
<refsection id="SERVICECONTROL" xreflabel="SERVICECONTROL">
<title>service status/control subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">status</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">show</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">find</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<group choice="req">
<arg choice="plain">try-restart</arg>
<arg choice="plain">try-reload-or-restart</arg>
<arg choice="plain">condrestart</arg>
<arg choice="plain">force-reload</arg>
</group>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">hangup</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">is-active</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">is-loaded</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">is-enabled</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">unload-when-stopped</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
<command>system-control</command> takes each of the <arg choice="plain"><replaceable>names</replaceable></arg>, searches for the corresponding service bundle directory, constructs a list of directory names, and chains to other commands with those directory names as <arg choice="plain"><replaceable>directories</replaceable></arg> arguments:
</para>

<table>
<title>status/control commands:</title>
<thead>
<tr><th>subcommand</th><th>chains to</th></tr>
</thead>
<tbody>
<tr><td><command>status</command></td><td>
<citerefentry><refentrytitle>service-status</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice="plain">--</arg> <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>show</command></td><td>
<citerefentry><refentrytitle>service-show</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>show-json</command></td><td>
<citerefentry><refentrytitle>service-show</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice='plain'>--json</arg> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>find</command></td><td>
<citerefentry><refentrytitle>ls</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice='plain'>-1d</arg> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><group><arg choice="plain"><command>try-restart</command></arg> <arg choice="plain"><command>try-reload-or-restart</command></arg> <arg choice="plain"><command>force-reload</command></arg> <arg choice="plain"><command>condrestart</command></arg></group></td><td>
<citerefentry><refentrytitle>service-control</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice='plain'>--terminate</arg> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>hangup</command></td><td>
<citerefentry><refentrytitle>service-control</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice='plain'>--hangup-main</arg> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>unload-when-stopped</command></td><td>
<citerefentry><refentrytitle>service-control</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice='plain'>--exit</arg> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>is-active</command></td><td>
<citerefentry><refentrytitle>service-is-up</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>is-loaded</command></td><td>
<citerefentry><refentrytitle>service-is-ok</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
<tr><td><command>is-enabled</command></td><td>
<citerefentry><refentrytitle>service-is-enabled</refentrytitle><manvolnum>1</manvolnum></citerefentry> <arg choice="plain">--</arg>  <arg choice="plain" repeat="rep"><replaceable>directories</replaceable></arg>
</td></tr>
</tbody>
</table>

</refsection>
<refsection id="CONVERTSYSTEMDUNITS" xreflabel="CONVERTSYSTEMDUNITS">
<title>script conversion subcommand</title>

<para>
For brevity, this is documented on a standalone <citerefentry><refentrytitle>convert-systemd-units</refentrytitle><manvolnum>1</manvolnum></citerefentry> manual page.
</para>

</refsection>
<refsection id="FSTABCONVERSION" xreflabel="FSTABCONVERSION">
<title>fstab conversion subcommand</title>

<para>
For brevity, this is documented on standalone <citerefentry><refentrytitle>convert-fstab-services</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>write-volume-service-bundles</refentrytitle><manvolnum>1</manvolnum></citerefentry> manual pages.
</para>

</refsection>

<refsection id="ESCAPE" xreflabel="ESCAPE">
<title>conversion utility subcommand</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">escape</arg>
<arg choice='opt'>--format <replaceable>escfmt</replaceable></arg>
<arg choice='opt'>--prefix <replaceable>prefix</replaceable></arg>
<arg choice="req" repeat="rep"><replaceable>name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
The <command>escape</command> subcommand takes each <replaceable>name</replaceable> and converts it using the escaping rules used in the <command>convert-systemd-units</command> subcommand.
Each escaped <replaceable>name</replaceable> is written to standard output, separated from its predecessor (if any) by a space and prefixed with <replaceable>prefix</replaceable> (which is not escaped).
</para>

<para>
The <arg choice='plain'>--escape-format</arg> option controls the escaping algorithm, according to the value of <replaceable>escfmt</replaceable>:
</para>
<variablelist>
<varlistentry>
<term><code>systemd</code></term>
<listitem><para>
This is the default escaping algorithm if no escaping algorithm is specified, and is the conventional systemd one that escapes <filename>/</filename> and <filename>-</filename>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><code>old-alt</code></term>
<listitem><para>
This is an old alternative algorithm that used to be used by <command>convert-systemd-units</command>, made available here for ease of use in upgrading old account names.
It is similar to the <code>systemd</code> algorithm except that it escapes almost all non-alphanumerics, encoding them in hexadecimal.
(e.g. <filename>ossec@agentd</filename> is converted to <filename>ossec_x40agentd</filename>.)
The escape character is <quote><code>_</code></quote> on most systems, except those where <quote><code>\</code></quote> is known to be legal in account names; it is of course itself escaped.
</para></listitem>
</varlistentry>
<varlistentry>
<term><code>alt</code></term>
<listitem><para>
This is the current alternative algorithm used by <command>convert-systemd-units</command>, where the escaped form is suitable for an account name in the system account database.
It is similar to the <code>old-alt</code> algorithm except that for a few common characters a shorter non-hexadecimal escape is used.
(e.g. <filename>ossec@agentd</filename> is converted to <filename>ossec_aagentd</filename>.)
</para></listitem>
</varlistentry>
<varlistentry>
<term><code>hash</code></term>
<listitem><para>
This abbreviates to the initial letters of each alphanumeric word, and appends a base-36 encoded DJBT33A hash of all of the alphanumeric characters.
(e.g. <filename>tinysshd-makekey</filename> is converted to <filename>tm-atdegy</filename>.)
Differently punctuated versions of the same string of words will have the same hash, therefore, but short strings that differ in the alphanumerics will very likely have different hashes.
An accidental but helpful property of this hash choice is that names that end in a series of ascending characters (e.g. 0, 1, 2, 3, 4, 5, 6, 7) will have likewise ascending encoded hash values.
</para></listitem>
</varlistentry>
<varlistentry>
<term><code>account</code></term>
<listitem><para>
This is the <code>alt</code> form, except when it would be over the allowable length for a system account name, less 4 (left as room for a verbatim suffix such as <filename>-log</filename>), when the <code>hash</code> form is used instead.
(e.g. <filename>getty@tty00</filename> is converted to <filename>getty_atty00</filename>, but <filename>mdnsresponderposix</filename> on NetBSD is converted to <filename>m-j1xhb0</filename>.)
</para></listitem>
For most operating systems, where <code>L_cuserid</code> and <citerefentry><refentrytitle>cuserid</refentrytitle><manvolnum>3</manvolnum></citerefentry> are relics, and the account database in fact has no inherent account name field length limit because it is a Berkeley DB file, the allowable length is at least 32 characters.
</varlistentry>
</variablelist>

</refsection>

<refsection id="NAGIOS" xreflabel="NAGIOS">
<title>Nagios plug-in subcommand</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">nagios-check-service</arg>
<arg choice='opt'>--min-seconds <replaceable>seconds</replaceable></arg>
<arg choice="opt">--critical-if-below-min</arg>
<arg choice='req' repeat="rep"><replaceable>name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
This subcommand is intended for use as a Nagios plug-in.
It queries the status API in the bundle directory for service/target <arg choice='plain'><replaceable>name</replaceable></arg>.
</para>

<itemizedlist>
<listitem>
<para>
If the service is up for longer than <arg choice='plain'><replaceable>seconds</replaceable></arg> seconds it returns a Nagios "OK" status.
</para>
</listitem>
<listitem>
<para>
If the service is up, but for less than <arg choice='plain'><replaceable>seconds</replaceable></arg> seconds it returns a Nagios "WARNING" status and prints a line containing the service bundle directory name.
It does the same if the service is still in the process of being loaded by the service manager, or in the starting or stopping states.
The <arg choice="plain">--critical-if-below-min</arg> command line option changes the status returned for such up services to "CRITICAL", but does not alter the treatment of starting or stopping services.
</para>
</listitem>
<listitem>
<para>
If the service is unexpectedly down or unloaded, if the status API reports the service running in the future (because of clock skew somewhere), or if the service is in the failing state, it returns a Nagios "CRITICAL" status and prints a line containing the service bundle directory name.
</para>
</listitem>
</itemizedlist>

</refsection>

<refsection id="KERNELMODULE" xreflabel="KERNELMODULE">
<title>Kernel module management subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">load-kernel-module</arg>
<arg choice='req' repeat="rep"><replaceable>module</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">unload-kernel-module</arg>
<arg choice='req' repeat="rep"><replaceable>module</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
These subcommands provide a minimal operating-system-neutral kernel module loading and unloading mechanism, for use in cross-platform service bundles.
They devolve to the appropriate operating system commands, which are <citerefentry><refentrytitle>kldload</refentrytitle><manvolnum>8</manvolnum></citerefentry> and <citerefentry><refentrytitle>kldunload</refentrytitle><manvolnum>8</manvolnum></citerefentry> on FreeBSD, <citerefentry><refentrytitle>modload</refentrytitle><manvolnum>8</manvolnum></citerefentry> and <citerefentry><refentrytitle>modunload</refentrytitle><manvolnum>8</manvolnum></citerefentry> on NetBSD, and <citerefentry><refentrytitle>modprobe</refentrytitle><manvolnum>8</manvolnum></citerefentry> (without or with the <arg choice='plain'>--remove</arg> option) on Linux.
</para>

</refsection>
<refsection id="PRINTSERVICESCRIPTS" xreflabel="PRINTSERVICESCRIPTS">
<title>service program dump subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">print-service-scripts</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">cat</arg>
<arg repeat="rep"><replaceable>names</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
<command>system-control</command> takes each of the <arg choice="plain"><replaceable>names</replaceable></arg>, searches for the corresponding service bundle directory, changes to the corresponding service directory, and runs <citerefentry><refentrytitle>grep</refentrytitle><manvolnum>1</manvolnum></citerefentry> to dump the contents of the <filename>start</filename>, <filename>stop</filename>, <filename>run</filename>, and <filename>restart</filename> files.
</para>

</refsection>
<refsection id="SERVICEENVIRONMENT" xreflabel="SERVICEENVIRONMENT">
<title>service environment manipulation subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">set-service-env</arg>
<arg choice="opt">--full</arg>
<arg choice="req"><replaceable>name</replaceable></arg>
<arg choice='req'><replaceable>var</replaceable></arg>
<arg><replaceable>value</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">print-service-env</arg>
<arg choice="opt">--full</arg>
<arg choice="req"><replaceable>name</replaceable></arg>
<arg><replaceable>var</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
If the <arg choice="plain"><replaceable>name</replaceable></arg> service has an environment template subdirectory named <filename>env/</filename> (in the format understood by <citerefentry><refentrytitle>envdir</refentrytitle><manvolnum>1</manvolnum></citerefentry>), these subcommands can be used to manipulate that template.
</para>

<itemizedlist>
<listitem><para>
<command>set-service-env</command> <arg choice="plain"><replaceable>name</replaceable></arg> <arg choice='plain'><replaceable>var</replaceable></arg> <arg choice='plain'><replaceable>value</replaceable></arg> sets <replaceable>var</replaceable> to <replaceable>value</replaceable> in the template, the change not (of course) affecting any currently running service.
</para></listitem>
<listitem><para>
<command>set-service-env</command> <arg choice="plain"><replaceable>name</replaceable></arg> <arg choice='plain'><replaceable>var</replaceable></arg> specifies that the template unset <replaceable>var</replaceable>, the change not (of course) affecting any currently running service.
</para></listitem>
<listitem><para>
<command>print-service-env</command> <arg choice="plain"><replaceable>name</replaceable></arg> <arg choice='plain'><replaceable>var</replaceable></arg> prints (only) the value of <replaceable>var</replaceable> from the template.
</para></listitem>
<listitem><para>
<command>print-service-env</command> <arg choice="plain"><replaceable>name</replaceable></arg> prints the whole template as list of <replaceable>var</replaceable>=<replaceable>value</replaceable> entries.
</para></listitem>
</itemizedlist>

<para>
The <arg choice="plain">--full</arg> command-line option switches to an alternative format for the environment template subdirectory, as understood by <citerefentry><refentrytitle>envdir</refentrytitle><manvolnum>1</manvolnum></citerefentry> when its option of the same name is used.
</para>

</refsection>
<refsection id="FSTABQUERY" xreflabel="FSTABQUERY">
<title>filesystem table query subcommands</title>

<refsynopsisdiv>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">get-mount-what</arg>
<arg ><replaceable>where</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>system-control</command>
<arg choice="req">get-mount-where</arg>
<arg ><replaceable>what</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<para>
These subcommands query the flat file table in <filename>/etc/fstab</filename> (see <citerefentry><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
They fill a gap left by the <citerefentry><refentrytitle>getent</refentrytitle><manvolnum>1</manvolnum></citerefentry> command, which has no subcommand for reading this table.
Like that command, they query the on-disc administrative database of what is configured to be mounted; not the kernel's list of currently active mounts.
</para>

<itemizedlist>
<listitem><para>
For a given mount-point <replaceable>where</replaceable> <command>get-mount-what</command> prints the volume that is configured to be mounted upon it.
</para></listitem>
<listitem><para>
For a given volume <replaceable>what</replaceable> <command>get-mount-where</command> prints the point where it is configured to be mounted.
</para></listitem>
</itemizedlist>

</refsection>

</refsection>

<refsection><title>Author</title>
<para><author><personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname></author></para>
</refsection>

</refentry>
