| 192 |
- |
1 |
#! /bin/sh -e
|
|
|
2 |
# Fallback Countdown
|
|
|
3 |
#
|
|
|
4 |
# This snippet depends on 10_reset_boot_success and needs to be kept in sync.
|
|
|
5 |
#
|
|
|
6 |
# The boot_counter env var can be used to count down boot attempts after an
|
|
|
7 |
# OSTree upgrade and choose the rollback deployment when 0 is reached.
|
|
|
8 |
# Both boot_counter=X and boot_success=1 need to be set from userspace.
|
|
|
9 |
cat << EOF
|
|
|
10 |
insmod increment
|
|
|
11 |
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
|
|
|
12 |
if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then
|
|
|
13 |
# if countdown has ended, choose to boot rollback deployment,
|
|
|
14 |
# i.e. default=1 on OSTree-based systems.
|
|
|
15 |
if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then
|
|
|
16 |
set default=1
|
|
|
17 |
set boot_counter=-1
|
|
|
18 |
# otherwise decrement boot_counter
|
|
|
19 |
else
|
|
|
20 |
decrement boot_counter
|
|
|
21 |
fi
|
|
|
22 |
save_env boot_counter
|
|
|
23 |
fi
|
|
|
24 |
EOF
|