grub2/0264-Add-comments-and-revert-logic-changes-in-01_fallback.patch

49 lines
1.6 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christian Glombek <lorbus@fedoraproject.org>
Date: Mon, 8 Oct 2018 11:57:04 +0200
Subject: [PATCH] Add comments and revert logic changes in 01_fallback_counting
---
util/grub.d/01_fallback_counting.in | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in
index 1a0b5fbecfc..be0e770ea82 100644
--- a/util/grub.d/01_fallback_counting.in
+++ b/util/grub.d/01_fallback_counting.in
@@ -1,19 +1,22 @@
#! /bin/sh -e
-if ! systemctl -q is-enabled greenboot.service >/dev/null 2>&1 ; then
- exit 0
-fi
-
# Boot Counting
+# The boot_counter env var can be used to count down boot attempts after an
+# OSTree upgrade and choose the rollback deployment when 0 is reached. Both
+# boot_counter and boot_success need to be (re-)set from userspace.
cat << EOF
insmod increment
-if [ -z "\${boot_counter}" ]; then
- set boot_counter=0
-elif [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then
- increment default
- set boot_counter=-1
-else
- decrement boot_counter
+# Check if boot_counter exists and boot_success=0 to activate this behaviour.
+if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then
+ # if countdown has ended, choose to boot rollback deployment (default=1 on
+ # OSTree-based systems)
+ if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then
+ set default=1
+ set boot_counter=-1
+ # otherwise decrement boot_counter
+ else
+ decrement boot_counter
+ fi
+ save_env boot_counter
fi
-save_env boot_counter
EOF