|
| 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 | +} |
0 commit comments