matrix:
container: [
"arch",
+ "gentoo",
]
network: [
"systemd-networkd",
]
test: [
+ "20",
+ "30",
"35",
"40",
]
+ exclude:
+ - container: "arch"
+ test: "20"
+ - container: "gentoo"
+ test: "40"
fail-fast: false
container:
image: ghcr.io/dracut-ng/${{ matrix.container }}
--- /dev/null
+[Match]
+Kind=!*
+Type=!loopback
+
+[Network]
+DHCP=yes
+
+[DHCPv4]
+ClientIdentifier=mac
+RequestOptions=17
+
+[DHCPv6]
+RequestOptions=59 60
--- /dev/null
+[Unit]
+Before=dracut-initqueue.service
+ConditionPathExists=/run/networkd/initrd/neednet
+
+[Service]
+TimeoutStartSec=120
+
+[Install]
+WantedBy=initrd.target
"$systemdsystemunitdir"/systemd-networkd-wait-online.service \
"$systemdsystemunitdir"/systemd-networkd-wait-online@.service \
"$systemdsystemunitdir"/systemd-network-generator.service \
- ip
+ ip sed grep
+
+ inst_simple "$moddir"/99-wait-online-dracut.conf \
+ "$systemdsystemunitdir"/systemd-networkd-wait-online.service.d/99-dracut.conf
+
+ inst_simple "$moddir"/99-default.network \
+ "$systemdnetworkconfdir"/99-default.network
+
+ inst_hook cmdline 99 "$moddir"/networkd-config.sh
+ inst_hook initqueue/settled 99 "$moddir"/networkd-run.sh
# Enable systemd type units
for i in \
--- /dev/null
+#!/bin/sh
+
+type getcmdline > /dev/null 2>&1 || . /lib/dracut-lib.sh
+
+# Just in case we're running before it
+systemctl start systemd-network-generator.service
+
+# Customizations for systemd-network-generator generated networks.
+# We need to request certain DHCP options, and there is no way to
+# tell the generator to add those.
+for f in /run/systemd/network/*.network; do
+ [ -f "$f" ] || continue
+
+ {
+ echo "[DHCPv4]"
+ echo "ClientIdentifier=mac"
+ echo "RequestOptions=17"
+ echo "[DHCPv6]"
+ echo "RequestOptions=59 60"
+ } >> "$f"
+done
+
+# Just in case networkd was already running
+systemctl try-reload-or-restart systemd-networkd.service
+
+if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then
+ echo rd.neednet >> /etc/cmdline.d/networkd.conf
+fi
+
+if getargbool 0 rd.neednet; then
+ mkdir -p /run/networkd/initrd
+ : > /run/networkd/initrd/neednet
+fi
--- /dev/null
+#!/bin/bash
+
+type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh
+
+for ifpath in /sys/class/net/*; do
+ ifname="$(basename "$ifpath")"
+
+ # shellcheck disable=SC2015
+ [ "$ifname" != "lo" ] && [ -e "$ifpath" ] && [ ! -e /tmp/networkd."$ifname".done ] || continue
+
+ if /usr/lib/systemd/systemd-networkd-wait-online --timeout=0.000001 --interface="$ifname" 2> /dev/null; then
+ leases_file="/run/systemd/netif/leases/$(cat "$ifpath"/ifindex)"
+ dhcpopts_file="/tmp/dhclient.${ifname}.dhcpopts"
+ if [ -r "$leases_file" ]; then
+ grep -E "^(NEXT_SERVER|ROOT_PATH)=" "$leases_file" \
+ | sed -e "s/NEXT_SERVER=/new_next_server='/" \
+ -e "s/ROOT_PATH=/new_root_path='/" \
+ -e "s/$/'/" > "$dhcpopts_file" || true
+ fi
+
+ source_hook initqueue/online "$ifname"
+ /sbin/netroot "$ifname"
+
+ : > /tmp/networkd."$ifname".done
+ fi
+done