]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat: systemd-battery-check dracut module
authorJo Zzsi <jozzsicsataban@gmail.com>
Sat, 9 Nov 2024 20:30:05 +0000 (15:30 -0500)
committerLaszlo <laszlo.gombos@gmail.com>
Sat, 9 Nov 2024 23:01:55 +0000 (18:01 -0500)
.github/labeler.yml
modules.d/01systemd-battery-check/module-setup.sh [new file with mode: 0755]
test/TEST-41-FULL-SYSTEMD/test.sh

index 279ee7b2d5ce88ae05823e5260c927066feae91d..ae425be9da1db8439783b25750af9850e1ebaa7e 100644 (file)
@@ -70,6 +70,10 @@ fips-crypto-policies:
   - changed-files:
     - any-glob-to-any-file: 'modules.d/[0-9][0-9]fips-crypto-policies/*'
 
+systemd-battery-check:
+  - changed-files:
+    - any-glob-to-any-file: 'modules.d/[0-9][0-9]systemd-battery-check/*'
+
 systemd-ac-power:
   - changed-files:
     - any-glob-to-any-file: 'modules.d/[0-9][0-9]systemd-ac-power/*'
diff --git a/modules.d/01systemd-battery-check/module-setup.sh b/modules.d/01systemd-battery-check/module-setup.sh
new file mode 100755 (executable)
index 0000000..64cdd0a
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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 "$systemdutildir"/systemd-battery-check || 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 systemd
+    # Return 0 to include the dependent module(s) in the initramfs.
+    return 0
+}
+
+# Install the required file(s) for the module in the initramfs.
+install() {
+    inst_multiple \
+        "$systemdsystemunitdir"/systemd-battery-check.service \
+        "$systemdsystemunitdir"/initrd.target.wants/systemd-battery-check.service \
+        "$systemdutildir"/systemd-battery-check
+}
index f7daebbd50725e903e7d32e06ebaee1c0c52f33d..1874dbccc91a7e5b7c2d64c6c169611cf37f4d73 100755 (executable)
@@ -135,7 +135,7 @@ EOF
     # TODO enable systemd-bsod for Gentoo
 
     test_dracut \
-        -m "resume dracut-systemd systemd-ac-power systemd-coredump systemd-creds systemd-cryptsetup systemd-integritysetup systemd-ldconfig systemd-pcrphase systemd-pstore systemd-repart systemd-sysext systemd-veritysetup" \
+        -m "systemd-battery-check resume dracut-systemd systemd-ac-power systemd-coredump systemd-creds systemd-cryptsetup systemd-integritysetup systemd-ldconfig systemd-pcrphase systemd-pstore systemd-repart systemd-sysext systemd-veritysetup" \
         --add-drivers "btrfs" \
         "$TESTDIR"/initramfs.testing