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).
master
Dusty Mabe 2021-04-13 11:45:35 -04:00 committed by Harald Hoyer
parent ac0e8f7dcc
commit 6a37c6f630
1 changed files with 13 additions and 9 deletions

View File

@ -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