]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
units: add first-boot-complete.target for first boot ordering
authorHarald Seiler <hws@denx.de>
Sun, 6 Sep 2020 19:23:36 +0000 (21:23 +0200)
committerHarald Seiler <hws@denx.de>
Mon, 19 Oct 2020 14:28:22 +0000 (16:28 +0200)
Add a new target for synchronizing units that wish to run once during
the first boot of the system.  The machine-id will be committed to disk
only after the target has been reached, thus ensuring that all units
ordered before it had a chance to complete.

man/systemd.special.xml
units/first-boot-complete.target [new file with mode: 0644]
units/meson.build
units/systemd-machine-id-commit.service

index e43d765c9fb3ff69d0587abb1ef5e2d864e8924a..1434ead7d5e8c74ad001cc175664045c14230144 100644 (file)
@@ -32,6 +32,7 @@
     <filename>emergency.target</filename>,
     <filename>exit.target</filename>,
     <filename>final.target</filename>,
+    <filename>first-boot-complete.target</filename>,
     <filename>getty.target</filename>,
     <filename>getty-pre.target</filename>,
     <filename>graphical.target</filename>,
             stopped.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><filename>first-boot-complete.target</filename></term>
+          <listitem>
+            <para>This passive target is intended as a synchronization point for units that need to run once
+            during the first boot.  Only after all units ordered before this target have finished, will the
+            <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+            be committed to disk, marking the first boot as completed.  If the boot is aborted at any time
+            before that, the next boot will re-run any units with <varname>ConditionFirstBoot=yes</varname>.
+            </para>
+          </listitem>
+        </varlistentry>
         <varlistentry>
           <term><filename>getty-pre.target</filename></term>
           <listitem>
diff --git a/units/first-boot-complete.target b/units/first-boot-complete.target
new file mode 100644 (file)
index 0000000..98b236e
--- /dev/null
@@ -0,0 +1,14 @@
+#  SPDX-License-Identifier: LGPL-2.1+
+#
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=First Boot Complete
+Documentation=man:systemd.special(7)
+RefuseManualStart=yes
+ConditionFirstBoot=yes
index e94e7f7efd99b26b91723736d560fda2233b82ba..40ffca5058ea85dfcfe9a9fdec4ffa140fccbaaf 100644 (file)
@@ -17,6 +17,7 @@ units = [
         ['emergency.target',                    ''],
         ['exit.target',                         ''],
         ['final.target',                        ''],
+        ['first-boot-complete.target',          ''],
         ['getty.target',                        '',
          'multi-user.target.wants/'],
         ['getty-pre.target',                    ''],
index e3acb0f3260bc30ae28d6556296c561fe145c7ec..5616a3570192670176ffa74239ef2110ebd6b235 100644 (file)
@@ -12,8 +12,8 @@ Description=Commit a transient machine-id on disk
 Documentation=man:systemd-machine-id-commit.service(8)
 DefaultDependencies=no
 Conflicts=shutdown.target
-Before=sysinit.target shutdown.target
-After=local-fs.target
+Before=shutdown.target
+After=local-fs.target first-boot-complete.target
 ConditionPathIsReadWrite=/etc
 ConditionPathIsMountPoint=/etc/machine-id