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