summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMole Shang <[email protected]>2023-06-22 20:40:43 +0800
committerMole Shang <[email protected]>2023-06-22 20:40:43 +0800
commit06a149b942a64e4686d67e6f59d94ffefc8c99b4 (patch)
tree1435d12ac81bf8c4435c1eb84cdfcb018080eed4
parent840b8600846e77b78f88172609deaf19a8a95de7 (diff)
downloaddotfiles-main.tar.gz
dotfiles-main.tar.bz2
dotfiles-main.zip
scripts/grub-reboot-selector: new, 20230622main
-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