Try booting up to 3 times on GRUB2 based systems (#2112)

* Retry up to 3 times

By default, HAOS used to retry 3 times. That is still true for U-Boot
based boards. Apply the same logic for GRUB2 based systems for
consistency.

This can help to remedy intermittent internet/connectivity issuese.
Altough hacky, in practise it makes sense to give the newly installed OS
another go.

* Also apply to generic-aarch64
This commit is contained in:
Stefan Agner
2022-09-06 20:28:14 +02:00
committed by GitHub
parent f4defcedfd
commit 30a0bb6d85
2 changed files with 54 additions and 18 deletions

View File

@@ -15,29 +15,43 @@ for SLOT in $ORDER; do
INDEX=0
OK=$A_OK
TRY=$A_TRY
A_TRY=1
fi
if [ "$SLOT" == "B" ]; then
INDEX=1
OK=$B_OK
TRY=$B_TRY
B_TRY=1
fi
if [ "$OK" -eq 1 -a "$TRY" -eq 0 ]; then
if [ "$OK" -eq 1 -a "$TRY" -lt 3 ]; then
default=$INDEX
# increment attempts and save back to slot
if [ "$TRY" -eq 1 ]; then
TRY=2
elif [ "$TRY" -eq 2 ]; then
TRY=3
else
TRY=1
fi
if [ "$SLOT" == "A" ]; then
A_TRY=$TRY
fi
if [ "$SLOT" == "B" ]; then
B_TRY=$TRY
fi
break
fi
done
# reset booted flags
# No bootable slot found, choose rescue...
if [ "$default" -eq 99 ]; then
if [ "$A_OK" -eq 1 -a "$A_TRY" -eq 1 ]; then
A_TRY=0
if [ "$A_OK" -eq 1 ]; then
default=2
fi
if [ "$B_OK" -eq 1 -a "$B_TRY" -eq 1 ]; then
B_TRY=0
if [ "$B_OK" -eq 1 ]; then
default=3
fi
default=0
fi
save_env A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID