]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/01systemd-sysusers/module-setup.sh
feat(dracut.sh): allow overriding the systemctl command for sysroot
[thirdparty/dracut.git] / modules.d / 01systemd-sysusers / module-setup.sh
1 #!/bin/sh
2 # This file is part of dracut.
3 # SPDX-License-Identifier: GPL-2.0-or-later
4
5 # Prerequisite check(s) for module.
6 check() {
7
8 # If the binary(s) requirements are not fulfilled
9 # return 1 to not include the binary.
10 require_binaries systemd-sysusers || return 1
11
12 # If the module dependency requirements are not fulfilled
13 # return 1 to not include the required module(s).
14 if ! dracut_module_included "systemd"; then
15 derror "systemd-sysuser needs systemd in the initramfs."
16 return 1
17 fi
18
19 # Return 255 to only include the module, if another module requires it.
20 return 255
21
22 }
23
24 # Module dependency requirements.
25 depends() {
26
27 # This module has external dependency on the systemd module.
28 echo systemd
29 # Return 0 to include the dependent systemd module in the initramfs.
30 return 0
31
32 }
33
34 # Install the required file(s) for the module in the initramfs.
35 install() {
36
37 inst_multiple -o \
38 # Install the system users and groups configuration file.
39 $sysusers/basic.conf \
40 # Install the systemd users and groups configuration file.
41 $sysusers/systemd.conf \
42 # Install the systemd type service unit for sysusers.
43 $systemdsystemunitdir/systemd-sysusers.service \
44 # Install the binary executable(s) for sysusers.
45 systemd-sysusers
46
47 # Install the hosts local user configurations if enabled.
48 if [[ $hostonly ]]; then
49 inst_multiple -H -o \
50 $sysusersconfdir/basic.conf \
51 $sysusersconfdir/systemd.conf \
52 $systemdsystemconfdir/systemd-sysusers.service \
53 $systemdsystemconfdir/systemd-sysusers.service.d/*.conf
54 ${NULL}
55 fi
56
57 # Enable the systemd type service unit for sysusers.
58 $SYSTEMCTL -q --root "$initdir" enable systemd-sysusers.service
59
60 }