added chroot part, locales and bootloader setup

This commit is contained in:
2024-12-29 23:09:53 +01:00
parent ceed7f8a8b
commit 48ccd1ca50
+72 -5
View File
@@ -55,26 +55,93 @@ setup_partitions() {
# Create filesystems # Create filesystems
mkfs.fat -F32 -n "BOOT" ${DISK}1 mkfs.fat -F32 -n "BOOT" ${DISK}1
mkswap ${DISK}3 mkswap -f ${DISK}3
mkfs.ext4 -L "ROOT" ${DISK}3 mkfs.ext4 -F -L "ROOT" ${DISK}3
# Mount # Mount
mount ${DISK}3 /mnt mount ${DISK}3 /mnt
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to mount the ROOT partition." echo "Failed to mount the ROOT partition."
return 1 # Exit if mounting ROOT partition fails exit 2 # Exit if mounting ROOT partition fails
fi fi
mount --mkdir ${DISK}1 /mnt/boot mount --mkdir ${DISK}1 /mnt/boot
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to mount the BOOT partition." echo "Failed to mount the BOOT partition."
return 1 # Exit if mounting BOOT partition fails exit 2 # Exit if mounting BOOT partition fails
fi fi
swapon ${DISK}2 swapon ${DISK}2
} }
# Setup systemdboot as the bootloader
setup_bootloader() {
bootctl install
BOOTLOADER_ENTRY="/boot/loader/entries/arch.conf"
ARCH_ENTRY_TEMPLATE="/usr/share/systemd/bootctl/arch.conf"
# Get PARTUUID for the root partition
PARTUUID=$(blkid | grep "${DISK}3" | awk -F= '{print $NF}' | tr -d '\"')
if [ -z "$PARTUUID" ]; then
echo "Error: Unable to find PARTUUID for ${DISK}3."
exit 3
fi
# Create a new entry based on the template and PARTUUID
echo "Creating bootloader entry with PARTUUID=$PARTUUID"
sed "s/^options.*/options root=PARTUUID=$PARTUUID rw splash/" "$ARCH_ENTRY_TEMPLATE" >"$BOOTLOADER_ENTRY"
if [ $? -eq 0 ]; then
echo "Successfully created bootloader entry: $BOOTLOADER_ENTRY"
else
echo "Error: Failed to create the bootloader entry."
exit 3
fi
}
# Main execution flow # Main execution flow
case $1 in
"install" | "")
# Ask for the drive to install on
get_drive get_drive
# cat /usr/share/systemd/bootctl/arch.conf | sed "s/^options.*/options root=PARTUUID=$(blkid | grep vda3 | awk -F= '{print $NF}' | tr -d '\"') rw splash/" >/boot/loader/entries/arch.conf # Partition, create filesystems and mount
setup_partitions
# Then install the kernel and some required packages
pacstrap -K /mnt base linux linux-firmware networkmanager
genfstab -U /mnt >>/mnt/etc/fstab
# Copy the script to the new environment for the chroot part
cp ./install.sh /mnt/tmp/
echo "DISK=${DISK}" >/mnt/etc/install-script-variables.conf
arch-chroot /mnt /bin/bash -c "/tmp/install.sh chroot"
umount -A -R /mnt # Unmount everything for safety
printf "\n==> Installation finished, you can now reboot.\n"
;;
"chroot")
echo "Running the chroot side"
. /tmp/install-script-variables.conf
# Setup base locales
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
locale-gen
echo LANG=en_US.UTF-8 >/etc/locale.conf
echo hostname >/etc/hostname
echo "root:password" | chpasswd
systemctl enable NetworkManager
setup_bootloader
;;
esac