| 1 |
<?xml version="1.0"?> |
| 2 |
<!--*-nxml-*--> |
| 3 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 4 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 5 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 6 |
<refentry id="systemd-run-generator"> |
| 7 |
|
| 8 |
<refentryinfo> |
| 9 |
<title>systemd-run-generator</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>systemd-run-generator</refentrytitle> |
| 15 |
<manvolnum>8</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>systemd-run-generator</refname> |
| 20 |
<refpurpose>Generator for invoking commands specified on the kernel command line as system service</refpurpose> |
| 21 |
</refnamediv> |
| 22 |
|
| 23 |
<refsynopsisdiv> |
| 24 |
<para><filename>/usr/lib/systemd/system-generators/systemd-run-generator</filename></para> |
| 25 |
</refsynopsisdiv> |
| 26 |
|
| 27 |
<refsect1> |
| 28 |
<title>Description</title> |
| 29 |
|
| 30 |
<para><filename>systemd-run-generator</filename> is a generator |
| 31 |
that reads the kernel command line and understands three |
| 32 |
options:</para> |
| 33 |
|
| 34 |
<para>If the <option>systemd.run=</option> option is specified and followed by a command line, a unit named |
| 35 |
<filename>kernel-command-line.service</filename> is generated for it and booted into. The service has |
| 36 |
<varname>Type=oneshot</varname> set, and has <varname>SuccessAction=exit</varname> and |
| 37 |
<varname>FailureAction=exit</varname> configured by default, thus ensuring that the system is shut down as soon as |
| 38 |
the command completes. The exit status of the command line is propagated to the invoking container manager, if |
| 39 |
this applies (which might propagate this further, to the calling shell — e.g. |
| 40 |
<citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> does this). If |
| 41 |
this option is used multiple times the unit file will contain multiple <varname>ExecStart=</varname> lines, to |
| 42 |
execute all commands in order. The command is started as regular service, i.e. with |
| 43 |
<varname>DefaultDependencies=</varname> on. </para> |
| 44 |
|
| 45 |
<para>Use <option>systemd.run_success_action=</option> and <option>systemd.run_failure_action=</option> to tweak |
| 46 |
how to react to the process completing. In particular assigning <literal>none</literal> will leave the system |
| 47 |
running after the command completes. For further details on supported arguments, see |
| 48 |
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
| 49 |
|
| 50 |
<para><filename>systemd-run-generator</filename> implements |
| 51 |
<citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para> |
| 52 |
</refsect1> |
| 53 |
|
| 54 |
<refsect1> |
| 55 |
<title>Example</title> |
| 56 |
|
| 57 |
<para>Use a command like the following to add a user to the user database inside a container run with |
| 58 |
<citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>:</para> |
| 59 |
|
| 60 |
<programlisting># systemd-nspawn -D mycontainer -b systemd.run='"adduser test"'</programlisting> |
| 61 |
<para>(Note the requirement for double quoting in the command line above. The first level of quoting ('') is |
| 62 |
processed and removed by the command shell used to invoke <command>systemd-nspawn</command>. The second level of |
| 63 |
quoting ("") is propagated to the kernel command line of the container and processed and removed by |
| 64 |
<command>systemd-run-generator</command>. Both together make sure both words of the specified command line |
| 65 |
<command>adduser test</command> end up in the generated unit file together and are neither split apart by the |
| 66 |
command shell nor by the generator.)</para> |
| 67 |
</refsect1> |
| 68 |
|
| 69 |
<refsect1> |
| 70 |
<title>See Also</title> |
| 71 |
<para><simplelist type="inline"> |
| 72 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 73 |
<member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 74 |
<member><citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 75 |
<member><citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 76 |
<member><citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 77 |
<member><citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 78 |
</simplelist></para> |
| 79 |
</refsect1> |
| 80 |
|
| 81 |
</refentry> |