summaryrefslogtreecommitdiffstats
path: root/modules.d/01systemd-networkd/networkd-run.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:33:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:33:11 +0000
commit203af7302854f453fa4a05ecefd4403b6c8a4f8d (patch)
tree967fdacafe332baabd12b57725505c138d0f3bbf /modules.d/01systemd-networkd/networkd-run.sh
parentAdding upstream version 102. (diff)
downloaddracut-87aa6639b3cd2285afa2ea598366934b1a158354.tar.xz
dracut-87aa6639b3cd2285afa2ea598366934b1a158354.zip
Adding upstream version 103.upstream/103upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules.d/01systemd-networkd/networkd-run.sh')
-rwxr-xr-xmodules.d/01systemd-networkd/networkd-run.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/modules.d/01systemd-networkd/networkd-run.sh b/modules.d/01systemd-networkd/networkd-run.sh
new file mode 100755
index 0000000..5445b46
--- /dev/null
+++ b/modules.d/01systemd-networkd/networkd-run.sh
@@ -0,0 +1,26 @@
+#!/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