]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat(systemd-timedated): introducing the systemd-timedated module
authorJóhann B. Guðmundsson <johannbg@gmail.com>
Wed, 14 Apr 2021 18:08:53 +0000 (18:08 +0000)
committerHarald Hoyer <harald@hoyer.xyz>
Thu, 22 Apr 2021 12:25:36 +0000 (14:25 +0200)
Introducing the systemd-timedated module

modules.d/01systemd-timedated/module-setup.sh [new file with mode: 0755]

diff --git a/modules.d/01systemd-timedated/module-setup.sh b/modules.d/01systemd-timedated/module-setup.sh
new file mode 100755 (executable)
index 0000000..af331ef
--- /dev/null
@@ -0,0 +1,43 @@
+#!/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 timedatectl || return 1
+    require_binaries "$systemdutildir"/systemd-timedated || return 1
+
+    # Return 255 to only include the module, if another module requires it.
+    return 255
+
+}
+
+# Module dependency requirements.
+depends() {
+
+    # This module has external dependency on other module(s).
+    echo dbus systemd
+    # Return 0 to include the dependent module(s) in the initramfs.
+    return 0
+
+}
+
+# Install the required file(s) and directories for the module in the initramfs.
+install() {
+
+    inst_multiple -o \
+        "$dbussystem"/org.freedesktop.timedate1.conf \
+        "$dbussystemservices"/org.freedesktop.timedate1.service \
+        "$systemdutildir"/systemd-timedated \
+        "$systemdsystemunitdir"/systemd-timedated.service \
+        timedatectl
+
+    # Install the hosts local user configurations if enabled.
+    if [[ $hostonly ]]; then
+        inst_multiple -H -o \
+            "$systemdsystemconfdir"/systemd-timedated.service \
+            "$systemdsystemconfdir"/systemd-timedated.service/*.conf
+    fi
+}