Skip to content

Commit

Permalink
fix(network-manager): only run NetworkManager if rd.neednet=1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dustymabe authored and haraldh committed Apr 16, 2021
1 parent 1f21fac commit ac0e8f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules.d/35network-manager/nm-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions modules.d/35network-manager/nm-run.service
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down

0 comments on commit ac0e8f7

Please sign in to comment.