From 5144dc0be7ee45410a890226717c64b233ee7b1a Mon Sep 17 00:00:00 2001 From: jbtrystram Date: Fri, 12 Apr 2024 10:08:00 +0200 Subject: [PATCH] Add missing wifi firmware checks Some wifi-firmwares will be split into sub-packages in fedora 40 We will keep them in until fedora 41, but display a warning message in the console if NetworkManager-wifi is layered without the most popular the wifi firmwares. See https://github.com/coreos/fedora-coreos-tracker/issues/1575 --- .../lib/systemd/system-preset/45-fcos.preset | 3 ++ .../coreos-check-wireless-firmwares.service | 10 +++++ .../libexec/coreos-check-wireless-firmwares | 45 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 overlay.d/15fcos/usr/lib/systemd/system/coreos-check-wireless-firmwares.service create mode 100755 overlay.d/15fcos/usr/libexec/coreos-check-wireless-firmwares diff --git a/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset b/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset index 27780787c9..95d8087d2b 100644 --- a/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset +++ b/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset @@ -3,3 +3,6 @@ enable coreos-check-ssh-keys.service enable coreos-check-cgroups-version.service # https://fedoraproject.org/wiki/Changes/EnableFwupdRefreshByDefault enable fwupd-refresh.timer +# Check if wifi firmwares are missing when NetworkManager-wifi is installed +# https://github.com/coreos/fedora-coreos-tracker/issues/1575 +enable coreos-check-wireless-firmwares.service diff --git a/overlay.d/15fcos/usr/lib/systemd/system/coreos-check-wireless-firmwares.service b/overlay.d/15fcos/usr/lib/systemd/system/coreos-check-wireless-firmwares.service new file mode 100644 index 0000000000..df2b5c7e2a --- /dev/null +++ b/overlay.d/15fcos/usr/lib/systemd/system/coreos-check-wireless-firmwares.service @@ -0,0 +1,10 @@ +# This service is used for printing a message if +# some wireless firmwares are missing +[Unit] +Description=Check if all the wireless firmwares are installed +[Service] +Type=oneshot +ExecStart=/usr/libexec/coreos-check-wireless-firmwares +RemainAfterExit=yes +[Install] +WantedBy=multi-user.target diff --git a/overlay.d/15fcos/usr/libexec/coreos-check-wireless-firmwares b/overlay.d/15fcos/usr/libexec/coreos-check-wireless-firmwares new file mode 100755 index 0000000000..7b6adb1557 --- /dev/null +++ b/overlay.d/15fcos/usr/libexec/coreos-check-wireless-firmwares @@ -0,0 +1,45 @@ +#!/usr/bin/bash +# This script checks if +# and will prints a message to the serial console +# to warn the user about missing wifi firmware messages +# and provide remediation steps +# See https://github.com/coreos/fedora-coreos-tracker/issues/1575 + +layered_packages="$(rpm-ostree status --json -b | jq -r '.deployments[0].packages[]')" + +if echo "$layered_packages" | grep -q "NetworkManager-wifi"; then + if echo "$layered_packages" | grep -q "atheros-firmware" && \ + echo "$layered_packages" | grep -q "brcmfmac-firmware" && \ + echo "$layered_packages" | grep -q "mt7xxx-firmware" && \ + echo "$layered_packages" | grep -q "realtek-firmware" + then + return 0 + fi +else + return 0 +fi + +# Change the output color to yellow +warn=$(echo -e '\033[0;33m') +# No color +nc=$(echo -e '\033[0m') + +motd_path=/run/motd.d/30_wireless_firmwares_warning.motd + +cat << EOF > "${motd_path}" +${warn} +########################################################################## +WARNING: The NetworkManager-wifi is installed on this system. +However, some wifi-firmwares are not installed. + +To layer the missing firmwares use the following : +sudo rpm-ostree install atheros-firmware brcmfmac-firmware \ +mt7xxx-firmware realtek-firmware + +Then reboot the system. + +To disable this warning, use: +sudo systemctl disable coreos-check-wireless-firmwares.service +########################################################################## +${nc} +EOF