]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.environment-generator.xml
bootctl: add a convenient way to print the path to EFI
[thirdparty/systemd.git] / man / systemd.environment-generator.xml
CommitLineData
1bd2d4e3
ZJS
1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4<!ENTITY % entities SYSTEM "custom-entities.ent" >
5%entities;
6]>
7
8<!--
9 This file is part of systemd.
10
11 Copyright 2017 Zbigniew Jędrzejewski-Szmek
12
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
17
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25-->
26
232bd677 27<refentry id="systemd.environment-generator" conditional='ENABLE_ENVIRONMENT_D'
28 xmlns:xi="http://www.w3.org/2001/XInclude">
1bd2d4e3
ZJS
29 <refentryinfo>
30 <title>systemd.environment-generator</title>
31 <productname>systemd</productname>
32
33 <authorgroup>
34 <author>
35 <contrib>Developer</contrib>
36 <firstname>Zbigniew</firstname>
37 <surname>Jędrzejewski-Szmek</surname>
38 <email>zbyszek@in.waw.pl</email>
39 </author>
40 </authorgroup>
41 </refentryinfo>
42
43 <refmeta>
44 <refentrytitle>systemd.environment-generator</refentrytitle>
45 <manvolnum>7</manvolnum>
46 </refmeta>
47
48 <refnamediv>
49 <refname>systemd.environment-generator</refname>
50 <refpurpose>Systemd environment file generators</refpurpose>
51 </refnamediv>
52
53 <refsynopsisdiv>
54 <cmdsynopsis>
55 <command>&systemenvgeneratordir;/some-generator</command>
56 </cmdsynopsis>
57 <cmdsynopsis>
58 <command>&userenvgeneratordir;/some-generator</command>
59 </cmdsynopsis>
60
61 <para>
62 <literallayout><filename>/run/systemd/system-environment-generators/*</filename>
63<filename>/etc/systemd/system-environment-generators/*</filename>
64<filename>/usr/local/lib/systemd/system-environment-generators/*</filename>
65<filename>&systemenvgeneratordir;/*</filename></literallayout>
66 </para>
67
68 <para>
69 <literallayout><filename>/run/systemd/user-environment-generators/*</filename>
70<filename>/etc/systemd/user-environment-generators/*</filename>
71<filename>/usr/local/lib/systemd/user-environment-generators/*</filename>
72<filename>&userenvgeneratordir;/*</filename></literallayout>
73 </para>
74 </refsynopsisdiv>
75
76 <refsect1>
77 <title>Description</title>
78 <para>Generators are small executables that live in
79 <filename>&systemenvgeneratordir;/</filename> and other directories listed above.
80 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> will
81 execute those binaries very early at the startup of each manager and at configuration
82 reload time, before running the generators described in
83 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>
84 and before starting any units. Environment generators can override the environment that the
85 manager exports to services and other processes.</para>
86
87 <para>Generators are loaded from a set of paths determined during compilation, as listed
88 above. System and user environment generators are loaded from directories with names ending in
89 <filename>system-environment-generators/</filename> and
90 <filename>user-environment-generators/</filename>, respectively. Generators found in directories
91 listed earlier override the ones with the same name in directories lower in the list. A symlink
92 to <filename>/dev/null</filename> or an empty file can be used to mask a generator, thereby
93 preventing it from running. Please note that the order of the two directories with the highest
94 priority is reversed with respect to the unit load path, and generators in
95 <filename>/run</filename> overwrite those in <filename>/etc</filename>.</para>
96
97 <para>After installing new generators or updating the configuration, <command>systemctl
98 daemon-reload</command> may be executed. This will re-run all generators, updating environment
99 configuration. It will be used for any services that are started subsequently.</para>
100
101 <para>Environment file generators are executed similarly to unit file generators described
102 in
103 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
104 with the following differences:</para>
105
106 <itemizedlist>
107 <listitem>
108 <para>Generators are executed sequentially in the alphanumerical order of the final
109 component of their name. The output of each generator output is immediately parsed and used
110 to update the environment for generators that run after that. Thus, later generators can use
111 and/or modify the output of earlier generators.</para>
112 </listitem>
113
114 <listitem>
115 <para>Generators are run by every manager instance, their output can be different for each
116 user.</para>
117 </listitem>
118 </itemizedlist>
119
120 <para>It is recommended to use numerical prefixes for generator names to simplify ordering.</para>
121 </refsect1>
122
123 <refsect1>
124 <title>Examples</title>
125
126 <example>
127 <title>A simple generator that extends an environment variable if a directory exists in the file system</title>
128
129 <programlisting># 50-xdg-data-dirs.sh
130
131<xi:include href="50-xdg-data-dirs.sh" parse="text" /></programlisting>
132 </example>
133
134 <example>
135 <title>A more complicated generator which reads existing configuration and mutates one variable</title>
136
137 <programlisting># 90-rearrange-path.py
138
139<xi:include href="90-rearrange-path.py" parse="text" /></programlisting>
140 </example>
141
142 <example>
143 <title>Debugging a generator</title>
144
145 <programlisting>SYSTEMD_LOG_LEVEL=debug VAR_A=something VAR_B="something else" \
146&systemenvgeneratordir;/path-to-generator
147</programlisting>
148 </example>
149 </refsect1>
150
151 <refsect1>
152 <title>See also</title>
153
154 <para>
f63c4aab 155 <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1bd2d4e3
ZJS
156 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
157 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
158 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
159 </para>
160 </refsect1>
161</refentry>