2 # This file is part of dracut.
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # Prerequisite check(s) for module.
8 # If the binary(s) requirements are not fulfilled the module can't be installed
9 require_binaries busctl ||
return 1
10 require_binaries dbus-daemon ||
return 1
11 require_binaries dbus-send ||
return 1
13 # Return 255 to only include the module, if another module requires it.
17 # Module dependency requirements.
20 # This module has external dependency on the systemd module.
22 # Return 0 to include the dependent systemd module in the initramfs.
26 # Install the required file(s) and directories for the module in the initramfs.
28 # dbus conflicts with dbus-broker.
29 if dracut_module_included
"dbus-broker"; then
30 derror
"dbus conflicts with dbus-broker in the initramfs."
34 # Create dbus related directories.
36 inst_dir
"$dbusinterfaces"
37 inst_dir
"$dbusservices"
38 inst_dir
"$dbussession"
39 inst_dir
"$dbussystem"
40 inst_dir
"$dbussystemservices"
41 inst_dir
"$dbusconfdir"
42 inst_dir
"$dbusinterfacesconfdir"
43 inst_dir
"$dbusservicesconfdir"
44 inst_dir
"$dbussessionconfdir"
45 inst_dir
"$dbussystemconfdir"
46 inst_dir
"$dbussystemservicesconfdir"
50 "$dbussystem"/org.freedesktop.systemd1.conf \
51 "$dbusservicesconfdir"/org.freedesktop.systemd1.service \
52 "$dbussystemservices"/org.freedesktop.systemd1.service \
53 "$systemdsystemunitdir"/dbus.service \
54 "$systemdsystemunitdir"/dbus.socket \
55 "$systemdsystemunitdir"/dbus.target.wants \
56 busctl dbus-send dbus-daemon
58 # Adjusting dependencies for initramfs in the dbus service unit.
59 # shellcheck disable=SC1004
61 '/^\[Unit\]/aDefaultDependencies=no\
62 Conflicts=shutdown.target\
63 Before=shutdown.target' \
64 "$initdir$systemdsystemunitdir/dbus.service"
66 # Adjusting dependencies for initramfs in the dbus socket unit.
67 # shellcheck disable=SC1004
69 '/^\[Unit\]/aDefaultDependencies=no\
70 Conflicts=shutdown.target\
71 Before=shutdown.target
72 /^\[Socket\]/aRemoveOnStop=yes' \
73 "$initdir$systemdsystemunitdir/dbus.socket"
75 # Adding the user and group for dbus
76 grep '^\(d\|message\)bus:' "$dracutsysrootdir"/etc
/passwd
>> "$initdir/etc/passwd"
77 grep '^\(d\|message\)bus:' "$dracutsysrootdir"/etc
/group
>> "$initdir/etc/group"
79 # Install the hosts local user configurations if enabled.
80 if [[ $hostonly ]]; then
82 "$dbusconfdir"/system.conf \
83 "$systemdsystemconfdir"/dbus.socket \
84 "$systemdsystemconfdir"/dbus.socket.d
/*.conf \
85 "$systemdsystemconfdir"/dbus.service \
86 "$systemdsystemconfdir"/dbus.service.d
/*.conf
89 # We need to make sure that systemd-tmpfiles-setup.service->dbus.socket
90 # will not wait for local-fs.target to start if swap is encrypted,
91 # this would make dbus wait the timeout for the swap before loading.
92 # This could delay sysinit services that are dependent on dbus.service.
94 '/^After/s/(After[[:space:]]*=.*)(local-fs.target[[:space:]]*)(.*)/\1-\.mount \3/' \
95 "$initdir$systemdsystemunitdir/systemd-tmpfiles-setup.service"