Skip to content

Commit b7d3cae

Browse files
johannbgharaldh
authored andcommitted
feat(systemd-resolved): introducing the systemd-resolved module
Introducing the systemd-resolved module
1 parent bf273e3 commit b7d3cae

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

dracut.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
329329
%{dracutlibdir}/modules.d/01systemd-initrd
330330
%{dracutlibdir}/modules.d/01systemd-modules-load
331331
%{dracutlibdir}/modules.d/01systemd-repart
332+
%{dracutlibdir}/modules.d/01systemd-resolved
332333
%{dracutlibdir}/modules.d/01systemd-sysctl
333334
%{dracutlibdir}/modules.d/01systemd-sysusers
334335
%{dracutlibdir}/modules.d/01systemd-timesyncd
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
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 the module can't be installed
9+
require_binaries resolvectl || return 1
10+
require_binaries "$systemdutildir"/systemd-resolved || return 1
11+
12+
# Return 255 to only include the module, if another module requires it.
13+
return 255
14+
15+
}
16+
17+
# Module dependency requirements.
18+
depends() {
19+
20+
# This module has external dependency on other module(s).
21+
echo dbus systemd-sysusers
22+
# Return 0 to include the dependent module(s) in the initramfs.
23+
return 0
24+
25+
}
26+
27+
# Install the required file(s) and directories for the module in the initramfs.
28+
install() {
29+
30+
inst_simple "$moddir/resolved-tmpfile-dracut.conf" "$tmpfilesdir/resolved-tmpfile-dracut.conf"
31+
32+
inst_multiple -o \
33+
"$dbussystem"/org.freedesktop.resolve1.conf \
34+
"$dbussystemservices"/org.freedesktop.resolve1.service \
35+
"$systemdutildir"/resolv.conf \
36+
"$systemdutildir"/resolved.conf \
37+
"$systemdutildir/resolved.conf.d/*.conf" \
38+
"$systemdutildir"/systemd-resolved \
39+
"$systemdsystemunitdir"/systemd-resolved.service \
40+
"$systemdsystemunitdir/systemd-resolved.service.d/*.conf" \
41+
resolvectl
42+
43+
# Enable systemd type unit(s)
44+
$SYSTEMCTL -q --root "$initdir" enable systemd-resolved.service
45+
46+
# Install library file(s)
47+
_arch=${DRACUT_ARCH:-$(uname -m)}
48+
inst_libdir_file \
49+
{"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
50+
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
51+
{"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
52+
{"tls/$_arch/",tls/,"$_arch/",}"libnss_resolve.so.*"
53+
54+
# Install the hosts local user configurations if enabled.
55+
if [[ $hostonly ]]; then
56+
inst_multiple -H -o \
57+
"$systemdutilconfdir"/resolved.conf \
58+
"$systemdutilconfdir/resolved.conf.d/*.conf" \
59+
"$systemdsystemconfdir"/systemd-resolved.service \
60+
"$systemdsystemconfdir/systemd-resolved.service/*.conf"
61+
fi
62+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file is part of dracut systemd-resolved module.
2+
L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf

0 commit comments

Comments
 (0)