]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(network-manager): disable tty output if the console is not usable
authorBeniamino Galvani <bgalvani@redhat.com>
Mon, 27 Sep 2021 11:25:55 +0000 (13:25 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Thu, 21 Oct 2021 13:38:41 +0000 (13:38 +0000)
The network-manager module also writes logs to the console, so that it's easier
to debug network-related boot issues. If systemd can't open the console, the
service fails and network doesn't get configured.

Add a check to disable tty output when the console is not present or not
usable.

https://github.com/coreos/fedora-coreos-tracker/issues/943

modules.d/35network-manager/nm-config.sh
modules.d/35network-manager/nm-initrd.service

index 85f89cb03d2c27660731f24a09b22d273faf6491..2b13d0a792448c5a2a212bb87d5136944155f4ed 100755 (executable)
@@ -18,12 +18,17 @@ if getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then
     ) > /run/NetworkManager/conf.d/initrd-logging.conf
 
     if [ -n "$DRACUT_SYSTEMD" ]; then
-        mkdir -p /run/systemd/system/nm-initrd.service.d
-        cat << EOF > /run/systemd/system/nm-initrd.service.d/tty-output.conf
+        # Enable tty output if a usable console is found
+        # See https://github.com/coreos/fedora-coreos-tracker/issues/943
+        # shellcheck disable=SC2217
+        if [ -w /dev/console ] && (echo < /dev/console) > /dev/null 2> /dev/null; then
+            mkdir -p /run/systemd/system/nm-initrd.service.d
+            cat << EOF > /run/systemd/system/nm-initrd.service.d/tty-output.conf
 [Service]
 StandardOutput=tty
 EOF
-        systemctl --no-block daemon-reload
+            systemctl --no-block daemon-reload
+        fi
     fi
 fi
 
index ad14e91ad1cb44324defc0bde3d0754be6d873f6..3e24f52a0aec5deeb3604e68ca80c99163afcb9f 100644 (file)
@@ -18,7 +18,7 @@ ExecReload=/usr/bin/busctl call org.freedesktop.NetworkManager /org/freedesktop/
 ExecStart=/usr/sbin/NetworkManager --debug
 KillMode=process
 # The following gets changed to StandardOutput=tty by nm-config.sh
-# when debug is enabled.
+# when debug is enabled and a usable console is found.
 StandardOutput=null
 Environment=NM_CONFIG_ENABLE_TAG=initrd
 Restart=on-failure