-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(network-manager): run as daemon with D-Bus
This commit changes how NM is started inside the initrd. Instead of running NM in the special --configure-and-quit=initrd mode, which sets up network and quits, start it as a daemon. This has multiple advantages. First, we no longer need to run NM in a special mode that requires additional code and maintenance. NetworkManager works exactly as in the real root. One problem of the current configure-and-quit approach is that once NM has quit, dynamic addresses can expire if the initrd setup takes longer than the DHCP lease interval or than the IPv6 address lifetime. Running NM as a service solves this problem. Now NM runs with D-Bus support and therefore its API can be used by other modules. This open the possibility, for example, to integrate nm-cloud-setup to automatically configure networking based on cloud metadata. Use the NetworkManager-wait-online.service, ordered before dracut-initqueue.service, to delay the initqueue until NM has terminated its configuration.
- Loading branch information
Showing
6 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[.config] | ||
enable=env:initrd | ||
|
||
[main] | ||
no-auto-default=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
Wants=systemd-udev-settle.service | ||
After=systemd-udev-settle.service | ||
Before=network.target | ||
ConditionPathExists=/run/NetworkManager/initrd/neednet | ||
ConditionPathExistsGlob=|/usr/lib/NetworkManager/system-connections/* | ||
ConditionPathExistsGlob=|/run/NetworkManager/system-connections/* | ||
ConditionPathExistsGlob=|/etc/NetworkManager/system-connections/* | ||
ConditionPathExistsGlob=|/etc/sysconfig/network-scripts/ifcfg-* | ||
|
||
[Service] | ||
Type=dbus | ||
BusName=org.freedesktop.NetworkManager | ||
ExecReload=/usr/bin/busctl call org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager Reload u 0 | ||
ExecStart=/usr/sbin/NetworkManager --debug | ||
KillMode=process | ||
StandardOutput=tty | ||
Environment=NM_CONFIG_ENABLE_TAG=initrd | ||
Restart=on-failure | ||
ProtectSystem=true | ||
ProtectHome=read-only | ||
|
||
[Install] | ||
WantedBy=initrd.target | ||
Also=nm-wait-online-initrd.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
Requires=nm-initrd.service | ||
After=nm-initrd.service | ||
Before=network-online.target | ||
Before=dracut-initqueue.service | ||
ConditionPathExists=/run/NetworkManager/initrd/neednet | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/nm-online -s -q | ||
RemainAfterExit=yes | ||
Environment=NM_ONLINE_TIMEOUT=3600 | ||
|
||
[Install] | ||
WantedBy=initrd.target | ||
WantedBy=network-online.target |