]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(network-manager): only run NetworkManager if rd.neednet=1
authorDusty Mabe <dusty@dustymabe.com>
Tue, 13 Apr 2021 15:36:21 +0000 (11:36 -0400)
committerHarald Hoyer <harald@hoyer.xyz>
Fri, 16 Apr 2021 09:12:49 +0000 (11:12 +0200)
Don't run the new systemd unit (nm-run.service) if rd.neednet=1
isn't set. nm-initrd-generator will generate configuration even
without rd.neednet=1 so determining if we should start based on
just if connection profiles exist isn't enough. We need some other
indicator. In this case we lay down a /run/NetworkManager/initrd/neednet
if rd.neednet=1, which is used by nm-run.service to determine the
need to run.

modules.d/35network-manager/nm-lib.sh
modules.d/35network-manager/nm-run.service

index c2a8cb834420d2983b37595d1a418f8832fe5664..012cc6285d1f34433ac6f62ae12ee6902bd12243 100644 (file)
@@ -14,6 +14,7 @@ nm_generate_connections() {
             /etc/sysconfig/network-scripts/ifcfg-*; do
             [ -f "$i" ] || continue
             echo '[ -f /tmp/nm.done ]' > "$hookdir"/initqueue/finished/nm.sh
+            : > /run/NetworkManager/initrd/neednet # activate nm-run.service
             break
         done
     fi
index b667ce3795972ddc9c706d017d4283ee5ce4ba80..f041ade89c644577a42989eb31f319a411b7ee97 100644 (file)
@@ -15,6 +15,9 @@ Before=network.target network-online.target
 #run before we try to mount anything from the dracut hooks
 Before=dracut-initqueue.service
 
+#do not run if networking not needed
+ConditionPathExists=/run/NetworkManager/initrd/neednet
+
 #do not run, if there is no configuration
 ConditionPathExistsGlob=|/usr/lib/NetworkManager/system-connections/*
 ConditionPathExistsGlob=|/run/NetworkManager/system-connections/*