|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Christian Glombek <lorbus@fedoraproject.org>
|
|
|
8e15ce |
Date: Tue, 2 Apr 2019 16:22:21 +0200
|
|
|
8e15ce |
Subject: [PATCH] grub.d: Split out boot success reset from menu auto hide
|
|
|
8e15ce |
script
|
|
|
8e15ce |
|
|
|
8e15ce |
Also rename fallback and menu auto hide script to be executed
|
|
|
8e15ce |
before and after boot success reset script.
|
|
|
8e15ce |
In menu auto hide script, rename last_boot_ok var to menu_hide_ok
|
|
|
b35c50 |
|
|
|
b35c50 |
Signed-off-by: Christian Glombek <lorbus@fedoraproject.org>
|
|
|
b35c50 |
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
|
|
8e15ce |
---
|
|
|
8e15ce |
Makefile.util.def | 14 ++++++++----
|
|
|
8e15ce |
...allback_counting.in => 08_fallback_counting.in} | 14 ++++++------
|
|
|
8e15ce |
util/grub.d/10_reset_boot_success.in | 25 ++++++++++++++++++++++
|
|
|
8e15ce |
.../{01_menu_auto_hide.in => 12_menu_auto_hide.in} | 23 +++++---------------
|
|
|
8e15ce |
4 files changed, 48 insertions(+), 28 deletions(-)
|
|
|
8e15ce |
rename util/grub.d/{01_fallback_counting.in => 08_fallback_counting.in} (65%)
|
|
|
8e15ce |
create mode 100644 util/grub.d/10_reset_boot_success.in
|
|
|
8e15ce |
rename util/grub.d/{01_menu_auto_hide.in => 12_menu_auto_hide.in} (58%)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/Makefile.util.def b/Makefile.util.def
|
|
|
b35c50 |
index e10fe766d1..b4ce5383b7 100644
|
|
|
8e15ce |
--- a/Makefile.util.def
|
|
|
8e15ce |
+++ b/Makefile.util.def
|
|
|
8e15ce |
@@ -459,14 +459,14 @@ script = {
|
|
|
8e15ce |
};
|
|
|
8e15ce |
|
|
|
8e15ce |
script = {
|
|
|
8e15ce |
- name = '01_fallback_counting';
|
|
|
8e15ce |
- common = util/grub.d/01_fallback_counting.in;
|
|
|
8e15ce |
+ name = '08_fallback_counting';
|
|
|
8e15ce |
+ common = util/grub.d/08_fallback_counting.in;
|
|
|
8e15ce |
installdir = grubconf;
|
|
|
8e15ce |
};
|
|
|
8e15ce |
|
|
|
8e15ce |
script = {
|
|
|
8e15ce |
- name = '01_menu_auto_hide';
|
|
|
8e15ce |
- common = util/grub.d/01_menu_auto_hide.in;
|
|
|
8e15ce |
+ name = '12_menu_auto_hide';
|
|
|
8e15ce |
+ common = util/grub.d/12_menu_auto_hide.in;
|
|
|
8e15ce |
installdir = grubconf;
|
|
|
8e15ce |
};
|
|
|
8e15ce |
|
|
|
8e15ce |
@@ -518,6 +518,12 @@ script = {
|
|
|
8e15ce |
condition = COND_HOST_LINUX;
|
|
|
8e15ce |
};
|
|
|
8e15ce |
|
|
|
8e15ce |
+script = {
|
|
|
8e15ce |
+ name = '10_reset_boot_success';
|
|
|
8e15ce |
+ common = util/grub.d/10_reset_boot_success.in;
|
|
|
8e15ce |
+ installdir = grubconf;
|
|
|
8e15ce |
+};
|
|
|
8e15ce |
+
|
|
|
8e15ce |
script = {
|
|
|
8e15ce |
name = '10_xnu';
|
|
|
8e15ce |
common = util/grub.d/10_xnu.in;
|
|
|
8e15ce |
diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/08_fallback_counting.in
|
|
|
8e15ce |
similarity index 65%
|
|
|
8e15ce |
rename from util/grub.d/01_fallback_counting.in
|
|
|
8e15ce |
rename to util/grub.d/08_fallback_counting.in
|
|
|
b35c50 |
index be0e770ea8..2e2c3ff7d3 100644
|
|
|
8e15ce |
--- a/util/grub.d/01_fallback_counting.in
|
|
|
8e15ce |
+++ b/util/grub.d/08_fallback_counting.in
|
|
|
8e15ce |
@@ -1,15 +1,17 @@
|
|
|
8e15ce |
#! /bin/sh -e
|
|
|
8e15ce |
-
|
|
|
8e15ce |
-# Boot Counting
|
|
|
8e15ce |
+# Fallback Countdown
|
|
|
8e15ce |
+#
|
|
|
8e15ce |
+# This snippet depends on 10_reset_boot_success and needs to be kept in sync.
|
|
|
8e15ce |
+#
|
|
|
8e15ce |
# The boot_counter env var can be used to count down boot attempts after an
|
|
|
8e15ce |
-# OSTree upgrade and choose the rollback deployment when 0 is reached. Both
|
|
|
8e15ce |
-# boot_counter and boot_success need to be (re-)set from userspace.
|
|
|
8e15ce |
+# OSTree upgrade and choose the rollback deployment when 0 is reached.
|
|
|
8e15ce |
+# Both boot_counter=X and boot_success=1 need to be set from userspace.
|
|
|
8e15ce |
cat << EOF
|
|
|
8e15ce |
insmod increment
|
|
|
8e15ce |
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
|
|
|
8e15ce |
if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then
|
|
|
8e15ce |
- # if countdown has ended, choose to boot rollback deployment (default=1 on
|
|
|
8e15ce |
- # OSTree-based systems)
|
|
|
8e15ce |
+ # if countdown has ended, choose to boot rollback deployment,
|
|
|
8e15ce |
+ # i.e. default=1 on OSTree-based systems.
|
|
|
8e15ce |
if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then
|
|
|
8e15ce |
set default=1
|
|
|
8e15ce |
set boot_counter=-1
|
|
|
8e15ce |
diff --git a/util/grub.d/10_reset_boot_success.in b/util/grub.d/10_reset_boot_success.in
|
|
|
8e15ce |
new file mode 100644
|
|
|
b35c50 |
index 0000000000..6c88d933dd
|
|
|
8e15ce |
--- /dev/null
|
|
|
8e15ce |
+++ b/util/grub.d/10_reset_boot_success.in
|
|
|
8e15ce |
@@ -0,0 +1,25 @@
|
|
|
8e15ce |
+#! /bin/sh -e
|
|
|
8e15ce |
+# Reset Boot Success
|
|
|
8e15ce |
+#
|
|
|
8e15ce |
+# The 08_fallback_counting and 12_menu_auto_hide snippets rely on this one
|
|
|
8e15ce |
+# and need to be kept in sync.
|
|
|
8e15ce |
+#
|
|
|
8e15ce |
+# The boot_success var needs to be set to 1 from userspace to mark a boot successful.
|
|
|
8e15ce |
+cat << EOF
|
|
|
8e15ce |
+insmod increment
|
|
|
8e15ce |
+# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
|
|
|
8e15ce |
+if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then
|
|
|
8e15ce |
+ set menu_hide_ok=1
|
|
|
8e15ce |
+else
|
|
|
8e15ce |
+ set menu_hide_ok=0
|
|
|
8e15ce |
+fi
|
|
|
8e15ce |
+# Reset boot_indeterminate after a successful boot, increment otherwise
|
|
|
8e15ce |
+if [ "\${boot_success}" = "1" ] ; then
|
|
|
8e15ce |
+ set boot_indeterminate=0
|
|
|
8e15ce |
+else
|
|
|
8e15ce |
+ increment boot_indeterminate
|
|
|
8e15ce |
+fi
|
|
|
8e15ce |
+# Reset boot_success for current boot
|
|
|
8e15ce |
+set boot_success=0
|
|
|
8e15ce |
+save_env boot_success boot_indeterminate
|
|
|
8e15ce |
+EOF
|
|
|
8e15ce |
diff --git a/util/grub.d/01_menu_auto_hide.in b/util/grub.d/12_menu_auto_hide.in
|
|
|
8e15ce |
similarity index 58%
|
|
|
8e15ce |
rename from util/grub.d/01_menu_auto_hide.in
|
|
|
8e15ce |
rename to util/grub.d/12_menu_auto_hide.in
|
|
|
b35c50 |
index ad175870a5..6a7c0fa0d4 100644
|
|
|
8e15ce |
--- a/util/grub.d/01_menu_auto_hide.in
|
|
|
8e15ce |
+++ b/util/grub.d/12_menu_auto_hide.in
|
|
|
8e15ce |
@@ -1,5 +1,8 @@
|
|
|
8e15ce |
#! /bin/sh
|
|
|
8e15ce |
-
|
|
|
8e15ce |
+# Menu Auto Hide
|
|
|
8e15ce |
+#
|
|
|
8e15ce |
+# This snippet depends on 10_reset_boot_success and needs to be kept in sync.
|
|
|
8e15ce |
+#
|
|
|
8e15ce |
# Disable / skip generating menu-auto-hide config parts on serial terminals
|
|
|
8e15ce |
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
|
|
8e15ce |
case "$x" in
|
|
|
8e15ce |
@@ -10,29 +13,13 @@ for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
|
|
8e15ce |
done
|
|
|
8e15ce |
|
|
|
8e15ce |
cat << EOF
|
|
|
8e15ce |
-if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then
|
|
|
8e15ce |
- set last_boot_ok=1
|
|
|
8e15ce |
-else
|
|
|
8e15ce |
- set last_boot_ok=0
|
|
|
8e15ce |
-fi
|
|
|
8e15ce |
-
|
|
|
8e15ce |
-# Reset boot_indeterminate after a successful boot
|
|
|
8e15ce |
-if [ "\${boot_success}" = "1" ] ; then
|
|
|
8e15ce |
- set boot_indeterminate=0
|
|
|
8e15ce |
-# Avoid boot_indeterminate causing the menu to be hidden more then once
|
|
|
8e15ce |
-elif [ "\${boot_indeterminate}" = "1" ]; then
|
|
|
8e15ce |
- set boot_indeterminate=2
|
|
|
8e15ce |
-fi
|
|
|
8e15ce |
-set boot_success=0
|
|
|
8e15ce |
-save_env boot_success boot_indeterminate
|
|
|
8e15ce |
-
|
|
|
8e15ce |
if [ x\$feature_timeout_style = xy ] ; then
|
|
|
8e15ce |
if [ "\${menu_show_once}" ]; then
|
|
|
8e15ce |
unset menu_show_once
|
|
|
8e15ce |
save_env menu_show_once
|
|
|
8e15ce |
set timeout_style=menu
|
|
|
8e15ce |
set timeout=60
|
|
|
8e15ce |
- elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then
|
|
|
8e15ce |
+ elif [ "\${menu_auto_hide}" -a "\${menu_hide_ok}" = "1" ]; then
|
|
|
8e15ce |
set orig_timeout_style=\${timeout_style}
|
|
|
8e15ce |
set orig_timeout=\${timeout}
|
|
|
8e15ce |
if [ "\${fastboot}" = "1" ]; then
|