Last active
August 29, 2022 10:52
-
-
Save Hayao0819/16fb4e2badac87ad1c81f9b1d907e68c to your computer and use it in GitHub Desktop.
指定したOSで再起動するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeu -o pipefail | |
# shellcheck source=/dev/null | |
source /dev/stdin < <(curl -sL "https://github.com/Hayao0819/FasBashLib/releases/download/v0.2.5/fasbashlib.sh") | |
(( "$UID" == 0 )) || { Msg.Err "Please run as root."; exit 1; } | |
readarray -t EntryList < <(awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg | grep -v "^$") | |
LastEntry=$( | |
last="$(grub-editenv list | cut -d "=" -f 2-)" | |
[[ -n "${last-""}" ]] || exit 0 | |
eval "Array=($(grep "$last" /boot/grub/grub.cfg))" | |
# shellcheck disable=SC2154 | |
echo "${Array[1]}" | |
) | |
grub-reboot "$(Choice -d "$LastEntry" -p "Select an entry to boot:" "${EntryList[@]}")" && reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment