1
0
mirror of https://github.com/home-assistant/operating-system.git synced 2026-04-19 08:19:50 +01:00
Files
operating-system/buildroot-external/rootfs-overlay/usr/libexec/raucdb-update
Jan Čermák 48bf9b5056 Move rauc.db to boot partition (#3810)
* Move rauc.db to boot partition

The RAUC metadata file contains information that is tightly related to the
system and kernel partitions. With the possibility to migrate data disk, the
rauc.db can contain bogus information when moved to a different system. Removal
of the file on "device wipe" is also not desirable, because the information
about slot status is lost.

Relocate the rauc.db to the boot partition after a system upgrade (as this
can't be handled by RAUC hooks, because it needs to be executed after all slots
and metadata is written) and adjust the script for recreating it. The downside
is that its content in /mnt/data would be recreated if the boot slot is changed
or system downgraded but this should be handled quite gracefully.

Also remove the raucdb-first-boot service which is no longer necessary
with the file not present in the data partition.

* Fix shellcheck and mount path
2025-01-21 18:40:07 +01:00

45 lines
1004 B
Bash
Executable File

#!/bin/sh
# shellcheck disable=SC1091
set -e
# Remove rauc.db from old location before migration in HAOS 15.
if [ -f /mnt/data/rauc.db ]; then
rm -f /mnt/data/rauc.db
fi
if grep -q 'slot\.boot\.0' /mnt/boot/rauc.db; then
echo "[INFO] rauc.db already contains slot information"
exit 0
fi
echo "[INFO] Generating rauc.db from os-release data"
eval "$(rauc status --output-format=shell)"
if [ -z "${RAUC_SYSTEM_BOOTED_BOOTNAME}" ]; then
echo "[ERROR] RAUC_SYSTEM_BOOTED_BOOTNAME is empty"
exit 1
fi
CURRENT_SLOT_ID=$(test "${RAUC_SYSTEM_BOOTED_BOOTNAME}" = "A" && echo 0 || echo 1)
. /etc/os-release
cat >> /mnt/boot/rauc.db <<EOF
[slot.boot.0]
bundle.compatible=${RAUC_SYSTEM_COMPATIBLE}
bundle.version=${VERSION_ID}
[slot.kernel.${CURRENT_SLOT_ID}]
bundle.compatible=${RAUC_SYSTEM_COMPATIBLE}
bundle.version=${VERSION_ID}
[slot.rootfs.${CURRENT_SLOT_ID}]
bundle.compatible=${RAUC_SYSTEM_COMPATIBLE}
bundle.version=${VERSION_ID}
EOF
/usr/bin/systemctl restart rauc.service