mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-28 07:26:28 +00:00
Fix RAUC tryboot handler set-state idempotency, add more checks (#3891)
When RPi is booted in the tryboot state and the set-state operation is called for the second time, the tryboot files don't exists anymore and the handler exits with an error code, printing an error in the Supervisor logs. Fix handling of this case and add few more checks to make the handler a bit more robust/traceable.
This commit is contained in:
parent
8531e7b57d
commit
56e3a377db
@ -73,9 +73,8 @@ case "$1" in
|
|||||||
slot_bootname="$2"
|
slot_bootname="$2"
|
||||||
new_state="$3"
|
new_state="$3"
|
||||||
echo "tryboot set-state $slot_bootname $new_state" >&2
|
echo "tryboot set-state $slot_bootname $new_state" >&2
|
||||||
if [ "${new_state}" = "good" ]; then
|
|
||||||
touch "${boot_dir}/slot-${slot_bootname}/.good"
|
if [ "${new_state}" != "good" ]; then
|
||||||
else
|
|
||||||
rm -f "${boot_dir}/slot-${slot_bootname}/.good"
|
rm -f "${boot_dir}/slot-${slot_bootname}/.good"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -85,6 +84,20 @@ case "$1" in
|
|||||||
|
|
||||||
# Check if tryboot is active
|
# Check if tryboot is active
|
||||||
if ! cmp -s -n 4 /proc/device-tree/chosen/bootloader/tryboot /dev/zero; then
|
if ! cmp -s -n 4 /proc/device-tree/chosen/bootloader/tryboot /dev/zero; then
|
||||||
|
if [ ! -f "${boot_dir}/cmdline-tryboot.txt" ]; then
|
||||||
|
if [ -f "${boot_dir}/slot-${slot_bootname}/.good" ]; then
|
||||||
|
# Most probably already handled on this boot before, do nothing
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "cmdline-tryboot.txt not found, can't commit current state." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# tryboot.txt MUST exist at this point
|
||||||
|
if [ ! -f "${boot_dir}/tryboot.txt" ]; then
|
||||||
|
echo "tryboot.txt not found, can't commit current state." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
cmdline_tryboot=$(head -n1 "${boot_dir}/cmdline-tryboot.txt")
|
cmdline_tryboot=$(head -n1 "${boot_dir}/cmdline-tryboot.txt")
|
||||||
tryboot_slot=$(get_value rauc.slot "${cmdline_tryboot}")
|
tryboot_slot=$(get_value rauc.slot "${cmdline_tryboot}")
|
||||||
if [ "${tryboot_slot}" != "${slot_bootname}" ]; then
|
if [ "${tryboot_slot}" != "${slot_bootname}" ]; then
|
||||||
@ -98,6 +111,10 @@ case "$1" in
|
|||||||
rm "${boot_dir}/tryboot.txt"
|
rm "${boot_dir}/tryboot.txt"
|
||||||
rm /run/systemd/reboot-param
|
rm /run/systemd/reboot-param
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${new_state}" = "good" ]; then
|
||||||
|
touch "${boot_dir}/slot-${slot_bootname}/.good"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
get-current)
|
get-current)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user