diff options
author | Mole Shang <[email protected]> | 2023-06-22 20:40:43 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2023-06-22 20:40:43 +0800 |
commit | 06a149b942a64e4686d67e6f59d94ffefc8c99b4 (patch) | |
tree | 1435d12ac81bf8c4435c1eb84cdfcb018080eed4 | |
parent | 840b8600846e77b78f88172609deaf19a8a95de7 (diff) | |
download | dotfiles-main.tar.gz dotfiles-main.tar.bz2 dotfiles-main.zip |
scripts/grub-reboot-selector: new, 20230622main
-rwxr-xr-x | scripts/grub-reboot-selector | 20 |
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 |