60 lines
1.7 KiB
Bash
Executable File
60 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Read config file, if it exists
|
|
configFileName=${HOME}/ArchTitus/install.conf
|
|
if [ -e "$configFileName" ]; then
|
|
echo "Using configuration file $configFileName."
|
|
. $configFileName
|
|
fi
|
|
|
|
# Check partitions are mounted
|
|
if ! grep -qs '/boot ' /proc/mounts; then
|
|
umount -fl /mnt
|
|
~/ArchTitus/x-mount.sh
|
|
arch-chroot /mnt /root/ArchTitus/x-bootloader.sh
|
|
echo "Done. Please reboot and/or try again if needed".
|
|
exit
|
|
fi
|
|
|
|
# install grub
|
|
if [[ ! -d "/sys/firmware/efi" ]]; then
|
|
pacman -S grub --noconfirm --needed
|
|
echo "Detected BIOS..."
|
|
if [ -z "$disk" ]; then
|
|
lsblk
|
|
echo "Please enter disk to install bootloader to: (example /dev/sda)"
|
|
read disk
|
|
disk="${disk,,}"
|
|
if [[ "${disk}" != *"/dev/"* ]]; then
|
|
disk="/dev/${disk}"
|
|
fi
|
|
else
|
|
echo "Installing BIOS GRUB to $disk."
|
|
fi
|
|
grub-install --boot-directory=/boot $disk
|
|
fi
|
|
if [[ -d "/sys/firmware/efi" ]]; then
|
|
pacman -S grub efibootmgr --noconfirm --needed
|
|
echo "Detected EFI..."
|
|
grub-install --efi-directory=/boot
|
|
fi
|
|
|
|
grubfile=/boot/grub/grub.cfg
|
|
grub-mkconfig -o $grubfile
|
|
|
|
if [[ -s $grubfile ]]; then
|
|
cat $grubfile
|
|
echo "$grubfile exists and not empty"
|
|
read -n 1 -s -r -p "Press any key to continue...or manually break script here."
|
|
else
|
|
echo ""
|
|
echo "$grubfile doesn't exist or is empty. Is grub downloading correctly?".
|
|
echo "Sometimes file wont exist, or a grub.new file is presnet in /boot/grub"
|
|
echo "Other times the file will be blank and grub-mkconfig outputs nothing..."
|
|
echo "Try again or break the script here and investigate"
|
|
echo "you'll find the following commands useful to investigate"
|
|
echo "arch-chroot /mnt"
|
|
echo "grub-mkconfig -o $grubfile"
|
|
read -n 1 -s -r -p "Press any key to continue...or manually break script here."
|
|
fi
|