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