Rename boot entries with old naming scheme

A new naming scheme for boot entries was introduced in
version 2014.5 [1]. We need to rename the old ones to this
new scheme before running `ostree admin kargs edit-in-place`.
Otherwise, the updated bootloader configuration will be written
to a new file instead of updating the existing one making the
system not bootable.

[1] https://github.com/ostreedev/ostree/pull/3206
Resolves: RHEL-45151
This commit is contained in:
Miguel Martín 2024-09-09 08:00:32 +02:00
parent 02da3dd3c4
commit 22916589d6
No known key found for this signature in database
GPG Key ID: 399C0C41974AC700

View File

@ -4,6 +4,15 @@
set -euo pipefail
rename_boot_entries() {
local -r boot_entries="$(find /boot/loader/entries -name 'ostree-*-*\.conf')"
for boot_entry in ${boot_entries} ; do
new_boot_entry=$(echo "${boot_entry}" | sed -e 's/ostree-\([1-9]\+\).*/ostree-\1.conf/')
echo "Renaming ${boot_entry} to ${new_boot_entry}"
mv "${boot_entry}" "${new_boot_entry}"
done
}
main() {
# Used to condition execution of this unit at the systemd level
local -r stamp_file="/var/lib/.ostree-readonly-sysroot"
@ -19,6 +28,10 @@ main() {
exit 0
fi
# A new naming for bootboot entries was introduced in 2024.5
# version: https://github.com/ostreedev/ostree/pull/3206
[[ "${OSTREE_SYSROOT_OPTS:-none}" == *bootboot-naming-1* ]] || rename_boot_entries
local -r boot_entries="$(ls -A /boot/loader/entries/ | wc -l)"
# Ensure that we can read BLS entries to avoid touching systems where /boot