2024-05-23 16:49:21 +00:00
|
|
|
#!/bin/sh
|
2024-09-07 19:13:10 +00:00
|
|
|
echo "We just need to ask some questions before installing"
|
2024-05-23 16:49:21 +00:00
|
|
|
# Get drive values for installation
|
|
|
|
lsblk
|
|
|
|
read -p 'Please enter the drive value for the root partition, this partition will be wiped and formatted: ' rootpar
|
|
|
|
read -p 'Please enter the drive value for the EFI partition: ' efipar
|
|
|
|
# Format the root partition to ext4
|
|
|
|
mkfs.ext4 /dev/$rootpar
|
|
|
|
# Mount root partition
|
|
|
|
mount /dev/$rootpar /mnt
|
2024-09-07 18:52:57 +00:00
|
|
|
# Ask if the EFI partition should be wiped before mounting
|
|
|
|
read -p "Do you wish to wipe the EFI partition? If you already have an existing OS installed, say No. " yesno
|
|
|
|
case $yesno in
|
|
|
|
[yesYesYy]* )
|
|
|
|
mkfs.fat -F32 /dev/$efipar
|
|
|
|
;;
|
|
|
|
[noNoNn]* )
|
|
|
|
echo "The EFI partition will not be wiped"
|
|
|
|
;;
|
|
|
|
* ) echo "Please answer yes (Yes, y, Y) or no (No, n, N)";;
|
|
|
|
esac
|
|
|
|
# Ask if a home partition should be created
|
|
|
|
read -p "Do you wish to set a home partition? " yesno
|
2024-05-23 16:49:21 +00:00
|
|
|
case $yesno in
|
2024-09-07 18:52:57 +00:00
|
|
|
[yesYesYy]* )
|
2024-09-07 19:13:10 +00:00
|
|
|
read -p 'Please enter the drive value for the home partition, this partition will be wiped: ' homepar
|
2024-05-23 16:49:21 +00:00
|
|
|
mkfs.ext4 /dev/$homepar
|
2024-09-07 18:52:57 +00:00
|
|
|
mount /dev/$homepar /mnt/home
|
2024-05-23 16:49:21 +00:00
|
|
|
;;
|
|
|
|
[noNoNn]* )
|
2024-09-07 18:52:57 +00:00
|
|
|
echo "A home partition will not be used in this installation"
|
2024-05-23 16:49:21 +00:00
|
|
|
;;
|
|
|
|
* ) echo "Please answer yes (Yes, y, Y) or no (No, n, N)";;
|
|
|
|
esac
|
2024-09-07 19:13:10 +00:00
|
|
|
# Get user credentials
|
|
|
|
read -p "Please enter a username " username
|
|
|
|
read -p "Please enter a password " password
|
|
|
|
read -p "Please re-enter the password " passwordconfirm
|
|
|
|
if [[ "$password" == "$password2" ]]; then
|
|
|
|
export USERNAME = $username
|
|
|
|
export PASSWORD = $password
|
|
|
|
echo "Credentials saved"
|
|
|
|
fi
|
|
|
|
# Set hostname, timezone and keyboard mapping
|
|
|
|
# We don't need to prompt for these since they will rarely change
|
|
|
|
export HOSTNAME="archlinux"
|
|
|
|
# Run pacstrap and install base packages
|
|
|
|
pacstrap -i /mnt base base-devel linux linux-firmware linux-headers intel-ucode git openssh rsync networkmanager grub efibootmgr dosfstools os-prober nano dkms dbus-broker-units mkinitcpio iptables-nft
|
|
|
|
# Create the /boot/efi directory and mount the EFI partition to it
|
|
|
|
mkdir /mnt/boot/efi
|
|
|
|
mount /dev/$efipar /mnt/boot/efi
|
2024-05-23 16:49:21 +00:00
|
|
|
# Generate a fstab file
|
|
|
|
genfstab -U /mnt >> /mnt/etc/fstab
|
|
|
|
# Copy system config files into the new install
|
|
|
|
cp files/sys-pacman.conf /mnt/etc/pacman.conf.tmp
|
|
|
|
cp files/sys-locale.gen /mnt/etc/locale.gen
|
|
|
|
cp files/sys-environment /mnt/etc/environment
|
|
|
|
cp files/sys-grub /mnt/etc/default/grub
|
|
|
|
cp files/sys-hosts /mnt/etc/hosts
|
|
|
|
cp files/sys-network.conf /etc/sysctl.d/90-network.conf
|
2024-07-07 16:56:44 +00:00
|
|
|
cp files/sys-mkinitcpio.conf /etc/mkinitcpio.conf
|
2024-05-23 16:49:21 +00:00
|
|
|
# Create temporary directories to store files for later use
|
|
|
|
mkdir /mnt/buildscripts /mnt/userfiles
|
|
|
|
cp scripts/* /mnt/buildscripts
|
|
|
|
cp files/user-* /mnt/userfiles
|
2024-09-07 19:13:10 +00:00
|
|
|
# Chroot into the new system, do some setup based on earlier questions and run the next script
|
|
|
|
arch-chroot /mnt /bin/bash <<EOF
|
|
|
|
sed -i 's/^#en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen
|
|
|
|
locale-gen
|
|
|
|
pacman -S --noconfirm hunspell-en_gb
|
|
|
|
ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime
|
|
|
|
hwclock --systohc
|
|
|
|
locale-gen
|
|
|
|
echo LANG=en_GB.UTF-8 > /etc/locale.conf
|
|
|
|
echo "KEYMAP=uk" > /etc/vconsole.conf
|
|
|
|
sh /buildscripts/1-root-config.sh
|