15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: Christian Glombek <lorbus@fedoraproject.org>
15a2072
Date: Tue, 31 Jul 2018 11:12:06 +0200
dbfd2e6
Subject: [PATCH] Boot Counting
15a2072
dbfd2e6
Adds 01_fallback_counting.in script to support boot counting before
dbfd2e6
falling back to the previous menu entry automatically
15a2072
---
15a2072
 Makefile.util.def                   |  6 ++++++
15a2072
 util/grub.d/01_fallback_counting.in | 12 ++++++++++++
15a2072
 2 files changed, 18 insertions(+)
15a2072
 create mode 100644 util/grub.d/01_fallback_counting.in
15a2072
15a2072
diff --git a/Makefile.util.def b/Makefile.util.def
15a2072
index cba4d500198..c8cb91308d9 100644
15a2072
--- a/Makefile.util.def
15a2072
+++ b/Makefile.util.def
15a2072
@@ -448,6 +448,12 @@ script = {
15a2072
   installdir = grubconf;
15a2072
 };
15a2072
 
15a2072
+script = {
15a2072
+  name = '01_fallback_counting';
15a2072
+  common = util/grub.d/01_fallback_counting.in;
15a2072
+  installdir = grubconf;
15a2072
+};
15a2072
+
15a2072
 script = {
15a2072
   name = '01_menu_auto_hide';
15a2072
   common = util/grub.d/01_menu_auto_hide.in;
15a2072
diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in
15a2072
new file mode 100644
f0ceaa7
index 00000000000..ecfc7401474
15a2072
--- /dev/null
15a2072
+++ b/util/grub.d/01_fallback_counting.in
15a2072
@@ -0,0 +1,12 @@
15a2072
+#! /bin/sh -e
15a2072
+
15a2072
+# Boot Counting
f0ceaa7
+if [ "\${boot_counter}" -a "\${boot_success}" = "0" ]; then
15a2072
+  if  [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then
15a2072
+    set default=1
15a2072
+    set boot_counter=-1
15a2072
+  else
15a2072
+    set boot_counter=$((\${boot_counter}-1))
15a2072
+  fi
15a2072
+  save_env boot_counter
15a2072
+fi