Harald Hoyer 5f0dd7
From 3dcaa97ca4dcfa8092252a22df62c60941e59ce3 Mon Sep 17 00:00:00 2001
Harald Hoyer 5f0dd7
From: Beniamino Galvani <bgalvani@redhat.com>
Harald Hoyer 5f0dd7
Date: Wed, 11 Mar 2020 09:40:50 +0100
Harald Hoyer 5f0dd7
Subject: [PATCH] network-manager: ensure that nm-run.sh is executed when
Harald Hoyer 5f0dd7
 needed
Harald Hoyer 5f0dd7
Harald Hoyer 5f0dd7
The network-manager command line hook must install a
Harald Hoyer 5f0dd7
initqueue/finished hook to ensure that nm-run.sh is executed when
Harald Hoyer 5f0dd7
there are network connections to activate.
Harald Hoyer 5f0dd7
Harald Hoyer 5f0dd7
Fixes: #694
Harald Hoyer 5f0dd7
---
Harald Hoyer 5f0dd7
 modules.d/35network-manager/nm-config.sh | 11 +++++++++++
Harald Hoyer 5f0dd7
 modules.d/35network-manager/nm-run.sh    |  2 ++
Harald Hoyer 5f0dd7
 2 files changed, 13 insertions(+)
Harald Hoyer 5f0dd7
Harald Hoyer 5f0dd7
diff --git a/modules.d/35network-manager/nm-config.sh b/modules.d/35network-manager/nm-config.sh
Harald Hoyer 5f0dd7
index 1efa737c..39a1c8bd 100755
Harald Hoyer 5f0dd7
--- a/modules.d/35network-manager/nm-config.sh
Harald Hoyer 5f0dd7
+++ b/modules.d/35network-manager/nm-config.sh
Harald Hoyer 5f0dd7
@@ -5,3 +5,14 @@ if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then
Harald Hoyer 5f0dd7
 fi
Harald Hoyer 5f0dd7
 
Harald Hoyer 5f0dd7
 /usr/libexec/nm-initrd-generator -- $(getcmdline)
Harald Hoyer 5f0dd7
+
Harald Hoyer 5f0dd7
+if getargbool 0 rd.neednet; then
Harald Hoyer 5f0dd7
+  for i in /usr/lib/NetworkManager/system-connections/* \
Harald Hoyer 5f0dd7
+           /run/NetworkManager/system-connections/* \
Harald Hoyer 5f0dd7
+           /etc/NetworkManager/system-connections/* \
Harald Hoyer 5f0dd7
+           /etc/sysconfig/network-scripts/ifcfg-*; do
Harald Hoyer 5f0dd7
+    [ -f "$i" ] || continue
Harald Hoyer 5f0dd7
+    echo '[ -f /tmp/nm.done ]' >$hookdir/initqueue/finished/nm.sh
Harald Hoyer 5f0dd7
+    break
Harald Hoyer 5f0dd7
+  done
Harald Hoyer 5f0dd7
+fi
Harald Hoyer 5f0dd7
diff --git a/modules.d/35network-manager/nm-run.sh b/modules.d/35network-manager/nm-run.sh
Harald Hoyer 5f0dd7
index 4079b735..fc5280a1 100755
Harald Hoyer 5f0dd7
--- a/modules.d/35network-manager/nm-run.sh
Harald Hoyer 5f0dd7
+++ b/modules.d/35network-manager/nm-run.sh
Harald Hoyer 5f0dd7
@@ -22,3 +22,5 @@ do
Harald Hoyer 5f0dd7
     source_hook initqueue/online $ifname
Harald Hoyer 5f0dd7
     /sbin/netroot $ifname
Harald Hoyer 5f0dd7
 done
Harald Hoyer 5f0dd7
+
Harald Hoyer 5f0dd7
+> /tmp/nm.done
Harald Hoyer 5f0dd7