Commit 35514031 authored by Paolo Dongilli's avatar Paolo Dongilli
Browse files

run grub-install in chroot if EFI partition exists and computer was started using UEFI

parent 80a0cb59
#!/bin/bash
#
# Script for automated cloning and renaming of Fuss 9/10 client computers
# Script for automated cloning and renaming of FUSS 9/10 client computers
# using mac-address as unique identifier.
# Donato Florio 11 April 2019
#
......@@ -12,6 +12,7 @@
# Last modified 19 May 2020 --> little modification of the "dialog" interface
# Last modified 04 June 2020 --> little change to allow rejoin without cloning (just comment line "ocs-sr ..."
# Last modified 24 March 2021 --> modified the parts gathering info of disk and partitions
# Last modified 28 July 2021 --> run grub-install in chroot if EFI partition exists and computer was started using UEFI
#
# PRT 1 ---------------------------
......@@ -74,7 +75,7 @@ computerList="/home/partimag/computerList.txt"
macAddress=$(getNetStuff 2)
if ! grep $macAddress $computerList; then
dialog --title "FUSS FUCC" --msgbox "Hi,\nunfortunatley, there is no valid configuration to setup this computer. Please go through the next few steps to configure how to install this PC.\nPlease make sure that the file /home/clonezilla/computerList.txt is owned and writable by clonezilla, otherwise we'll not be able to save the informations you're going to enter." 13 70
dialog --title "FUSS FUCC" --msgbox "Hi,\nunfortunatley, there is no valid configuration to setup this computer. Please go through the next few steps to configure how to install this PC.\nPlease make sure that the file /home/clonezilla/computerList.txt is owned and writable by clonezilla, otherwise we'll not be able to save the information you're going to enter." 13 70
hostname=$(dialog --title "FUSS FUCC" --inputbox "Please, pick an HOSTNAME for this PC" --output-fd 1 10 70)
img=$(dialog --title "FUSS FUCC" --output-fd 1 --menu "Choose an image to be installed" 15 50 4 $(getImages))
# dialog --title "FUSS FUCC" --msgbox "Set image $img" 13 70
......@@ -106,14 +107,15 @@ rootPartition=$(getRootPartitionFuss)
# # PRT 2 ---------------------------
mount $rootPartition $mountPoint
# Check for EFI partition. If present mount it and install grub files ----------
# Check for EFI partition and if the system was booted using UEFI.
# If confirmed, mount it and run grub-install in chroot ---------------------------
efiPart=$(fdisk -l | grep EFI | awk '{print $1}')
if [ $efiPart ]; then
mkdir -p $mountPoint/boot/efi
if [ $efiPart ] && [ -d /sys/firmware/efi ]; then
mount $efiPart $mountPoint/boot/efi
grub-install --boot-directory=$mountPoint/boot --efi-directory=$mountPoint/boot/efi/
for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i $mountPoint$i; done
chroot $mountPoint grub-install /dev/$diskVar
fi
# -----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment