]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.environment-generator.xml
travis: add more ASan options
[thirdparty/systemd.git] / man / systemd.environment-generator.xml
CommitLineData
1bd2d4e3 1<?xml version='1.0'?> <!--*-nxml-*-->
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
1bd2d4e3
ZJS
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4<!ENTITY % entities SYSTEM "custom-entities.ent" >
5%entities;
6]>
0307f791 7<!-- SPDX-License-Identifier: LGPL-2.1+ -->
1bd2d4e3 8
232bd677 9<refentry id="systemd.environment-generator" conditional='ENABLE_ENVIRONMENT_D'
10 xmlns:xi="http://www.w3.org/2001/XInclude">
1bd2d4e3
ZJS
11 <refentryinfo>
12 <title>systemd.environment-generator</title>
13 <productname>systemd</productname>
1bd2d4e3
ZJS
14 </refentryinfo>
15
16 <refmeta>
17 <refentrytitle>systemd.environment-generator</refentrytitle>
18 <manvolnum>7</manvolnum>
19 </refmeta>
20
21 <refnamediv>
22 <refname>systemd.environment-generator</refname>
f95b0be7 23 <refpurpose>systemd environment file generators</refpurpose>
1bd2d4e3
ZJS
24 </refnamediv>
25
26 <refsynopsisdiv>
27 <cmdsynopsis>
28 <command>&systemenvgeneratordir;/some-generator</command>
29 </cmdsynopsis>
30 <cmdsynopsis>
31 <command>&userenvgeneratordir;/some-generator</command>
32 </cmdsynopsis>
33
34 <para>
35 <literallayout><filename>/run/systemd/system-environment-generators/*</filename>
36<filename>/etc/systemd/system-environment-generators/*</filename>
37<filename>/usr/local/lib/systemd/system-environment-generators/*</filename>
38<filename>&systemenvgeneratordir;/*</filename></literallayout>
39 </para>
40
41 <para>
42 <literallayout><filename>/run/systemd/user-environment-generators/*</filename>
43<filename>/etc/systemd/user-environment-generators/*</filename>
44<filename>/usr/local/lib/systemd/user-environment-generators/*</filename>
45<filename>&userenvgeneratordir;/*</filename></literallayout>
46 </para>
47 </refsynopsisdiv>
48
49 <refsect1>
50 <title>Description</title>
51 <para>Generators are small executables that live in
52 <filename>&systemenvgeneratordir;/</filename> and other directories listed above.
53 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> will
54 execute those binaries very early at the startup of each manager and at configuration
55 reload time, before running the generators described in
56 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>
57 and before starting any units. Environment generators can override the environment that the
58 manager exports to services and other processes.</para>
59
60 <para>Generators are loaded from a set of paths determined during compilation, as listed
61 above. System and user environment generators are loaded from directories with names ending in
62 <filename>system-environment-generators/</filename> and
63 <filename>user-environment-generators/</filename>, respectively. Generators found in directories
64 listed earlier override the ones with the same name in directories lower in the list. A symlink
65 to <filename>/dev/null</filename> or an empty file can be used to mask a generator, thereby
66 preventing it from running. Please note that the order of the two directories with the highest
67 priority is reversed with respect to the unit load path, and generators in
68 <filename>/run</filename> overwrite those in <filename>/etc</filename>.</para>
69
70 <para>After installing new generators or updating the configuration, <command>systemctl
71 daemon-reload</command> may be executed. This will re-run all generators, updating environment
72 configuration. It will be used for any services that are started subsequently.</para>
73
74 <para>Environment file generators are executed similarly to unit file generators described
75 in
76 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
77 with the following differences:</para>
78
79 <itemizedlist>
80 <listitem>
81 <para>Generators are executed sequentially in the alphanumerical order of the final
82 component of their name. The output of each generator output is immediately parsed and used
83 to update the environment for generators that run after that. Thus, later generators can use
84 and/or modify the output of earlier generators.</para>
85 </listitem>
86
87 <listitem>
88 <para>Generators are run by every manager instance, their output can be different for each
89 user.</para>
90 </listitem>
91 </itemizedlist>
92
93 <para>It is recommended to use numerical prefixes for generator names to simplify ordering.</para>
94 </refsect1>
95
96 <refsect1>
97 <title>Examples</title>
98
99 <example>
100 <title>A simple generator that extends an environment variable if a directory exists in the file system</title>
101
102 <programlisting># 50-xdg-data-dirs.sh
103
104<xi:include href="50-xdg-data-dirs.sh" parse="text" /></programlisting>
105 </example>
106
107 <example>
108 <title>A more complicated generator which reads existing configuration and mutates one variable</title>
109
110 <programlisting># 90-rearrange-path.py
111
112<xi:include href="90-rearrange-path.py" parse="text" /></programlisting>
113 </example>
114
115 <example>
116 <title>Debugging a generator</title>
117
118 <programlisting>SYSTEMD_LOG_LEVEL=debug VAR_A=something VAR_B="something else" \
119&systemenvgeneratordir;/path-to-generator
120</programlisting>
121 </example>
122 </refsect1>
123
124 <refsect1>
125 <title>See also</title>
126
127 <para>
f63c4aab 128 <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1bd2d4e3
ZJS
129 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
130 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
132 </para>
133 </refsect1>
134</refentry>