Skip to content

Commit

Permalink
fix(systemd-networkd): make systemd-networkd a proper network provider
Browse files Browse the repository at this point in the history
Make systemd-networkd a proper network service provider. Fixes #737
  • Loading branch information
johannbg authored and haraldh committed Apr 22, 2021
1 parent 0202125 commit ea77975
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 39 deletions.
91 changes: 53 additions & 38 deletions modules.d/02systemd-networkd/module-setup.sh
Original file line number Diff line number Diff line change
@@ -1,64 +1,79 @@
#!/bin/bash
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later

# called by dracut
# Prerequisite check(s) for module.
check() {
[[ $mount_needs ]] && return 1

# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries ip networkctl \
"$systemdutildir"/systemd-networkd \
"$systemdutildir"/systemd-network-generator \
"$systemdutildir"/systemd-networkd-wait-online \
|| return 1

# Return 255 to only include the module, if another module requires it.
return 255

}

# called by dracut
# Module dependency requirements.
depends() {
echo "systemd kernel-network-modules"
}

installkernel() {
# This module has external dependency on other module(s).
echo dbus kernel-network-modules systemd-sysusers
# Return 0 to include the dependent module(s) in the initramfs.
return 0

}

# called by dracut
# Install the required file(s) and directories for the module in the initramfs.
install() {

inst_multiple -o \
"$dbussystem"/org.freedesktop.network1.conf \
"$dbussystemservices"/org.freedesktop.network1.service \
"$systemdutildir"/networkd.conf \
"$systemdutildir/networkd.conf.d/*.conf" \
"$systemdutildir"/systemd-networkd \
"$systemdutildir"/systemd-network-generator \
"$systemdutildir"/systemd-networkd-wait-online \
"$systemdsystemunitdir"/systemd-networkd-wait-online.service \
"$systemdutildir"/network/80-container-host0.network \
"$systemdutildir"/network/80-container-ve.network \
"$systemdutildir"/network/80-container-vz.network \
"$systemdutildir"/network/80-vm-vt.network \
"$systemdutildir"/network/80-wifi-adhoc.network \
"$systemdutildir"/network/99-default.link \
"$systemdsystemunitdir"/systemd-networkd.service \
"$systemdsystemunitdir"/systemd-networkd.socket \
"$systemdutildir"/network/99-default.link \
"$systemdsystemunitdir"/systemd-network-generator.service \
"$systemdsystemunitdir"/systemd-networkd-wait-online.service \
"$systemdsystemunitdir"/systemd-network-generator.service \
networkctl ip

#hostnamectl timedatectl
# $systemdutildir/systemd-timesyncd \
# $systemdutildir/systemd-timedated \
# $systemdutildir/systemd-hostnamed \
# $systemdutildir/systemd-resolvd \
# $systemdutildir/systemd-resolve-host \
# $systemdsystemunitdir/systemd-resolved.service \
# $systemdsystemunitdir/systemd-hostnamed.service \
# $systemdsystemunitdir/systemd-timesyncd.service \
# $systemdsystemunitdir/systemd-timedated.service \
# $systemdsystemunitdir/time-sync.target \
# /etc/systemd/resolved.conf \

# inst_dir /var/lib/systemd/clock

grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"

_arch=${DRACUT_ARCH:-$(uname -m)}
inst_libdir_file \
{"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"libnss_resolve.so.*"

# systemd-timesyncd.service
# Enable systemd type units
for i in \
systemd-networkd-wait-online.service \
systemd-networkd.service \
systemd-networkd.socket; do
systemd-networkd.socket \
systemd-network-generator.service \
systemd-networkd-wait-online.service; do
$SYSTEMCTL -q --root "$initdir" enable "$i"
done

# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
"$systemdutilconfdir"/networkd.conf \
"$systemdutilconfdir/networkd.conf.d/*.conf" \
"$systemdutilconfdir/network/*" \
"$systemdsystemconfdir"/systemd-networkd.service \
"$systemdsystemconfdir/systemd-networkd.service/*.conf" \
"$systemdsystemunitdir"/systemd-networkd.socket \
"$systemdsystemunitdir/systemd-networkd.socket/*.conf" \
"$systemdsystemconfdir"/systemd-network-generator.service \
"$systemdsystemconfdir/systemd-network-generator.service/*.conf" \
"$systemdsystemconfdir"/systemd-networkd-wait-online.service \
"$systemdsystemconfdir/systemd-networkd-wait-online.service/*.conf"
fi
}
4 changes: 3 additions & 1 deletion modules.d/40network/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ check() {
depends() {
is_qemu_virtualized && echo -n "qemu-net "

for module in network-wicked network-manager network-legacy; do
for module in network-wicked network-manager network-legacy systemd-networkd; do
if dracut_module_included "$module"; then
network_handler="$module"
break
Expand All @@ -21,6 +21,8 @@ depends() {
network_handler="network-wicked"
elif [[ -x $dracutsysrootdir/usr/libexec/nm-initrd-generator ]]; then
network_handler="network-manager"
elif [[ -x $dracutsysrootdir/usr/lib/systemd/systemd-networkd ]]; then

This comment has been minimized.

Copy link
@shaba

shaba Apr 22, 2021

Contributor

$dracutsysrootdir/usr/lib/systemd/systemd-networkd -> $dracutsysrootdir$systemdutildir/systemd-networkd

network_handler="systemd-networkd"
else
network_handler="network-legacy"
fi
Expand Down

0 comments on commit ea77975

Please sign in to comment.