From 6a37c6f6302f950df608db3fd45acf9342ee3de2 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Tue, 13 Apr 2021 11:45:35 -0400 Subject: [PATCH 2/2] fix(network-manager): use /run/NetworkManager/initrd/neednet in initqueue We don't want to start NetworkManager if networking is not needed. Right now nm-config.sh lays down /usr/lib/dracut/hooks/initqueue/finished/nm.sh which will cause the initqueue to run. If nothing exists in /usr/lib/dracut/hooks/initqueue/finished/ then it will short circuit and the initqueue won't run anything. But what if something else needed something to run in the initqueue? nm-run.sh would still get started, even though /usr/lib/dracut/hooks/initqueue/finished/nm.sh didn't exist. In this case let's just trigger off of /run/NetworkManager/initrd/neednet like we are doing in the systemd unit (nm-run.service). --- modules.d/35network-manager/nm-run.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/modules.d/35network-manager/nm-run.sh b/modules.d/35network-manager/nm-run.sh index d48028df..359bc9ee 100755 --- a/modules.d/35network-manager/nm-run.sh +++ b/modules.d/35network-manager/nm-run.sh @@ -6,15 +6,19 @@ if [ -e /tmp/nm.done ]; then return fi -[ -z "$DRACUT_SYSTEMD" ] && \ -for i in /usr/lib/NetworkManager/system-connections/* \ - /run/NetworkManager/system-connections/* \ - /etc/NetworkManager/system-connections/* \ - /etc/sysconfig/network-scripts/ifcfg-*; do - [ -f "$i" ] || continue - /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon - break -done +if [ -z "$DRACUT_SYSTEMD" ]; then + # Only start NM if networking is needed + if [ -e /run/NetworkManager/initrd/neednet ]; then + for i in /usr/lib/NetworkManager/system-connections/* \ + /run/NetworkManager/system-connections/* \ + /etc/NetworkManager/system-connections/* \ + /etc/sysconfig/network-scripts/ifcfg-*; do + [ -f "$i" ] || continue + /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon + break + done + fi +fi if [ -s /run/NetworkManager/initrd/hostname ]; then cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname -- 2.30.2