Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlay/15fcos: fix aleph file and update bootloader for Secure Boot nodes #3042

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ 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
# Strip extraneous field in aleph files to avoid bootupctl failing
# https://github.com/coreos/fedora-coreos-tracker/issues/1724
enable coreos-fix-aleph-file.service
# Upgrade bootloader on Secure Boot-enabled nodes to avoid
# https://github.com/coreos/fedora-coreos-tracker/issues/1752
enable coreos-bootupctl-update-secureboot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Remove after the next barrier release

[Unit]
Description=Update Bootloader for Secure Boot-enabled Systems
Documentation=https://github.com/coreos/fedora-coreos-tracker/issues/1752
ConditionSecurity=uefi-secureboot

# make sure to run after the aleph file is fixed
# see https://github.com/coreos/fedora-coreos-tracker/issues/1724
After=coreos-fix-aleph-file.service
jbtrystram marked this conversation as resolved.
Show resolved Hide resolved
Requires=coreos-fix-aleph-file.service

[Service]
Type=oneshot
ExecStart=/usr/libexec/coreos-update-bootloader
RemainAfterExit=yes
MountFlags=slave

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Remove after the next barrier release

[Unit]
Description=Fix CoreOS Aleph File
Documentation=https://github.com/coreos/fedora-coreos-tracker/issues/1724

[Service]
Type=oneshot
ExecStart=/usr/libexec/coreos-fix-aleph-file
RemainAfterExit=yes
jbtrystram marked this conversation as resolved.
Show resolved Hide resolved
MountFlags=slave

[Install]
WantedBy=multi-user.target
28 changes: 28 additions & 0 deletions overlay.d/15fcos/usr/libexec/coreos-fix-aleph-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/bash

# This script removes the extra `version` field
# which was shipped in a couple of builds
# when switching to the `build` field
# To be removed after the next barrier release.
# see https://github.com/coreos/fedora-coreos-tracker/issues/1724 for more details

set -euo pipefail

ALEPH_FILE=/sysroot/.coreos-aleph-version.json

jlebon marked this conversation as resolved.
Show resolved Hide resolved
if ! jq -e 'has("build") and has("version")' ${ALEPH_FILE}; then
echo "Aleph file does not require fixing"
exit
fi

echo "Aleph file is invalid; fixing"

# remount /sysroot as writable
mount -o rw,remount /sysroot

# remove field "build"
fixed_aleph=$(jq 'del(.build)' ${ALEPH_FILE})

echo "$fixed_aleph" > ${ALEPH_FILE}

echo "Aleph file is fixed"
27 changes: 27 additions & 0 deletions overlay.d/15fcos/usr/libexec/coreos-update-bootloader
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail

# This script update the bootloader using bootupd
# and also detect RAID-1 setups as those requires
# extra steps

if [ -e /dev/disk/by-label/EFI-SYSTEM ]; then
echo "Found ESP; calling 'bootupctl update'"
bootupctl update
exit
fi
jbtrystram marked this conversation as resolved.
Show resolved Hide resolved

# handle RAID case manually since bootupd doesn't support it
# https://github.com/coreos/bootupd/issues/132
i=1
while true; do
if [ ! -e /dev/disk/by-label/esp-$i ]; then
break
fi
echo "Found ESP (replica $i); updating"
mount /dev/disk/by-label/esp-$i /boot/efi
cp -rp /usr/lib/bootupd/updates/EFI /boot/efi
umount /boot/efi
i=$((i+1))
done
sync
Loading