scripts/winboot

21 lines
599 B
Plaintext
Raw Normal View History

2016-12-19 17:45:17 +01:00
#!/bin/sh
GRUB_DEFAULT_PATH='/etc/default/grub'
2019-03-05 18:48:15 +01:00
WIN_GRUB="3"
2016-12-19 17:45:17 +01:00
if grep -q -E -- "^GRUB_DEFAULT=saved" "${GRUB_DEFAULT_PATH}"
then
printf '%b' "Reboot to windaube partition\n"
sudo grub-reboot "${WIN_GRUB}"
sudo systemctl reboot
else
printf '%b' "GRUB_DEFAULT is not set in 'saved' mode\n"
sudo sed -i 's/\(^GRUB_DEFAULT.*\)/#\1\nGRUB_DEFAULT=saved/' "${GRUB_DEFAULT_PATH}"
GRUB_DEFAULT_ENTRY=$(grep -E -- "#GRUB_DEFAULT=" "${GRUB_DEFAULT_PATH}" | cut -d"=" -f2)
sudo grub-set-default "${GRUB_DEFAULT_ENTRY}"
2016-12-19 17:45:17 +01:00
sudo update-grub
printf '%b' "Please launch this script once again.\n"
fi
exit 0