]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat(systemd-sysusers): run systemd-sysusers as part of the build process
authorJo Zzsi <jozzsicsataban@gmail.com>
Sat, 4 Jan 2025 23:45:32 +0000 (18:45 -0500)
committerLaszlo <laszlo.gombos@gmail.com>
Sat, 11 Jan 2025 02:30:57 +0000 (21:30 -0500)
This PR makes the boot process faster and the generated initrd smaller.

It also make the code easier to maintain.

The primary goal of this PR is refactoring and removing code,
this is why it is not marked as perf() in the commit.

That said, with this PR systemd-sysusers no longer needs to be copied
into the initrd, so that is about 50KB saving both on when initrd gets
saved/compressed and when it gets loaded and uncompressed.

This PR also make the debugging slightly easier as one can just
inspect /etc/passwd with lsinitrd instead of trying to figure out
which users are created runtime.

modules.d/01systemd-sysusers/module-setup.sh [deleted file]
modules.d/01systemd-sysusers/sysusers-dracut.conf [deleted file]
modules.d/60systemd-sysusers/module-setup.sh [new file with mode: 0755]

diff --git a/modules.d/01systemd-sysusers/module-setup.sh b/modules.d/01systemd-sysusers/module-setup.sh
deleted file mode 100755 (executable)
index 4c6b39d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-# This file is part of dracut.
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-# Prerequisite check(s) for module.
-check() {
-    # If the binary(s) requirements are not fulfilled the module can't be installed.
-    require_binaries systemd-sysusers || return 1
-
-    # Return 255 to only include the module, if another module requires it.
-    return 255
-}
-
-# Install the required file(s) and directories for the module in the initramfs.
-install() {
-    inst_simple "$moddir/sysusers-dracut.conf" "$systemdsystemunitdir/systemd-sysusers.service.d/sysusers-dracut.conf"
-
-    inst_sysusers basic.conf
-
-    inst_multiple -o \
-        "$systemdsystemunitdir"/systemd-sysusers.service \
-        "$systemdsystemunitdir"/sysinit.target.wants/systemd-sysusers.service \
-        systemd-sysusers
-
-    # Install the hosts local user configurations if enabled.
-    if [[ $hostonly ]]; then
-        inst_multiple -H -o \
-            "$systemdsystemconfdir"/systemd-sysusers.service \
-            "$systemdsystemconfdir/systemd-sysusers.service.d/*.conf"
-    fi
-}
diff --git a/modules.d/01systemd-sysusers/sysusers-dracut.conf b/modules.d/01systemd-sysusers/sysusers-dracut.conf
deleted file mode 100644 (file)
index 9b13364..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-[Unit]
-ConditionNeedsUpdate=
diff --git a/modules.d/60systemd-sysusers/module-setup.sh b/modules.d/60systemd-sysusers/module-setup.sh
new file mode 100755 (executable)
index 0000000..0568055
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+# This file is part of dracut.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Prerequisite check(s) for module.
+check() {
+    # If the binary(s) requirements are not fulfilled the module can't be installed.
+    require_binaries systemd-sysusers || return 1
+
+    # Return 255 to only include the module, if another module requires it.
+    return 255
+}
+
+# Install the required file(s) and directories for the module in the initramfs.
+install() {
+    inst_sysusers basic.conf
+
+    systemd-sysusers --root="$initdir"
+}