diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:33:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:33:11 +0000 |
commit | 203af7302854f453fa4a05ecefd4403b6c8a4f8d (patch) | |
tree | 967fdacafe332baabd12b57725505c138d0f3bbf /modules.d/01systemd-networkd/networkd-run.sh | |
parent | Adding upstream version 102. (diff) | |
download | dracut-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-x | modules.d/01systemd-networkd/networkd-run.sh | 26 |
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 |