summaryrefslogtreecommitdiff
path: root/scripts/grub-reboot-selector
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/grub-reboot-selector')
-rwxr-xr-xscripts/grub-reboot-selector20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/grub-reboot-selector b/scripts/grub-reboot-selector
new file mode 100755
index 0000000..377d9a8
--- /dev/null
+++ b/scripts/grub-reboot-selector
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Search for grub.cfg
+#GRUB_CFG=$(find /boot -name grub.cfg 2> /dev/null)
+GRUB_CFG="/boot/grub/grub.cfg"
+
+if [[ -z ${GRUB_CFG} ]]; then
+ echo "No grub.cfg found under /boot. Try as root."
+ exit 1
+elif [[ ! -r ${GRUB_CFG} ]]; then
+ echo "${GRUB_CFG} is not readable. Try as root."
+ exit 1
+fi
+
+GRUB_MENUENTRY=$(awk -F\' '/menuentry / {print $2}' ${GRUB_CFG} | fzf)
+
+# Set boot target for next boot
+grub-reboot "${GRUB_MENUENTRY}"
+
+systemctl reboot