Skip to content

Commit

Permalink
fix(network-manager): disable tty output if the console is not usable
Browse files Browse the repository at this point in the history
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.

coreos/fedora-coreos-tracker#943
(cherry picked from commit f6e6be245d0cda14d90a0442b688c8dca1410a2e)
  • Loading branch information
bengal authored and Vogtinator committed Mar 7, 2022
1 parent aa28d40 commit b221dc7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions modules.d/35network-manager/nm-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion modules.d/35network-manager/nm-initrd.service
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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
Expand Down

0 comments on commit b221dc7

Please sign in to comment.