]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(systemd-networkd): ensure zzzz-dracut-default.network cleanup
authorJo Zzsi <jozzsicsataban@gmail.com>
Thu, 8 Jan 2026 16:01:47 +0000 (11:01 -0500)
committerBenjamin Drung <bdrung@ubuntu.com>
Thu, 15 Jan 2026 15:56:39 +0000 (16:56 +0100)
zzzz-dracut-default.network should be only installed when
systemd-network-generator does not generate any files in
files in /run/systemd/network .

Place dracut-default.network in /usr/lib/dracut/
and do not change /usr as part of managing .network
files in initramfs.

Follow-up to 523c9b0 .

modules.d/11systemd-networkd/dracut-default.network [moved from modules.d/11systemd-networkd/99-default.network with 100% similarity]
modules.d/11systemd-networkd/module-setup.sh
modules.d/11systemd-networkd/networkd-config.sh

index 7aa34662800e2da6ac3de2f6542b3b6b377d7e65..61d73a0992988fc639ebfce9f1f19b16e1a12420 100755 (executable)
@@ -63,8 +63,7 @@ install() {
     inst_simple "$moddir"/99-wait-online-dracut.conf \
         "$systemdsystemunitdir"/systemd-networkd-wait-online.service.d/99-dracut.conf
 
-    inst_simple "$moddir"/99-default.network \
-        "$systemdnetwork"/zzzz-dracut-default.network
+    inst_simple "$moddir"/dracut-default.network /usr/lib/dracut/dracut-default.network
 
     inst_hook cmdline 99 "$moddir"/networkd-config.sh
     inst_hook initqueue/settled 99 "$moddir"/networkd-run.sh
index db6f4282a8e56519cd84c7974b7e15d3498fb7fe..89556ef151708bd15d8a5fe5ef6ca84f23088449 100755 (executable)
@@ -8,6 +8,7 @@ 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.
+generated=0
 for f in /run/systemd/network/*.network; do
     [ -f "$f" ] || continue
 
@@ -19,10 +20,15 @@ for f in /run/systemd/network/*.network; do
         echo "RequestOptions=59 60"
     } >> "$f"
 
-    # Remove the default network if at least one was generated
-    rm -f "$systemdnetworkconfdir"/zzzz-dracut-default.network
+    # at least one was generated
+    generated=1
 done
 
+# Add the default network if none was generated
+if [ "$generated" -eq "0" ]; then
+    cp -a /usr/lib/dracut/dracut-default.network /run/systemd/network/zzzz-dracut-default.network
+fi
+
 # Just in case networkd was already running
 systemctl try-reload-or-restart systemd-networkd.service