From a970ec3915171f3b640bdb32d30ad2f11d982fda Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 3 Apr 2023 10:50:10 +0200 Subject: [PATCH] Elevate GRUB scripts --- scripts/Arch/Software/GRUB/install.sh | 14 ++++++++++---- scripts/Common/Config/GRUB/setup.sh | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/scripts/Arch/Software/GRUB/install.sh b/scripts/Arch/Software/GRUB/install.sh index 1e4e3679..2cac3611 100755 --- a/scripts/Arch/Software/GRUB/install.sh +++ b/scripts/Arch/Software/GRUB/install.sh @@ -1,9 +1,15 @@ #!/bin/bash pushd "${BASH_SOURCE%/*}" > /dev/null; -EFI_BOOT_DIR="${EFI_BOOT_DIR:-"/boot"}"; -BOOTLOADER_ID=${BOOTLOADER_ID:-"GRUB"}; -pacman --noconfirm -Syu grub efibootmgr; -. ../../../Common/Config/GRUB/setup.sh; +# Elevate script +if [ ! "$UID" -eq 0 ] +then + sudo bash "$BASH_SOURCE" "$USER"; +else + EFI_BOOT_DIR="${EFI_BOOT_DIR:-"/boot"}"; + BOOTLOADER_ID=${BOOTLOADER_ID:-"GRUB"}; + pacman --noconfirm -Syu grub efibootmgr; + . ../../../Common/Config/GRUB/setup.sh; +fi; popd > /dev/null; diff --git a/scripts/Common/Config/GRUB/setup.sh b/scripts/Common/Config/GRUB/setup.sh index d40d222b..a2ee3571 100644 --- a/scripts/Common/Config/GRUB/setup.sh +++ b/scripts/Common/Config/GRUB/setup.sh @@ -1,7 +1,17 @@ #!/bin/bash EFI_BOOT_DIR="${EFI_BOOT_DIR}"; BOOTLOADER_ID="${BOOTLOADER_ID}"; -grub-install --target=x86_64-efi --efi-directory="$EFI_BOOT_DIR" --bootloader-id="$BOOTLOADER_ID"; -grub-mkconfig -o "$EFI_BOOT_DIR/grub/grub.cfg"; -sed -i "s/#\(GRUB_DISABLE_OS_PROBER\)/\1/" /etc/default/grub +# Elevate script +if [ ! "$UID" -eq 0 ] +then + sudo + EFI_BOOT_DIR="${EFI_BOOT_DIR}" \ + BOOTLOADER_ID="${BOOTLOADER_ID}" \ + bash "$BASH_SOURCE" "$USER"; +else + grub-install --target=x86_64-efi --efi-directory="$EFI_BOOT_DIR" --bootloader-id="$BOOTLOADER_ID"; + grub-mkconfig -o "$EFI_BOOT_DIR/grub/grub.cfg"; + + sed -i "s/#\(GRUB_DISABLE_OS_PROBER\)/\1/" /etc/default/grub +fi;