From 18ea24d85e05f5d2e1ba5b1f7885b0086ea261a3 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Tue, 20 Dec 2016 18:52:25 +0100 Subject: [PATCH] Ensure to define grub's default entry with grub- --- README.md | 1 + winboot | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index cda3529..fedbd20 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ Be sure to set the correct value to **WIN_GRUB** variable which must be the numb * The script will also modify the grub configuration : * Set Grub in "saved" mode. + * Ensure to set the previous default entry with `grub-set-default`. * Then for the reboot : * Choose the grub entry for the next reboot. * Reboot the system with ``systemctl``. diff --git a/winboot b/winboot index f60b2dc..f921a58 100755 --- a/winboot +++ b/winboot @@ -11,6 +11,8 @@ then 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}" sudo update-grub printf '%b' "Please launch this script once again.\n" fi