2021-05-22 10:49:31 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
echo "+===============================+"
|
|
|
|
echo "| Kalle's Arch Installer Script |"
|
|
|
|
echo "+===============================+"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Early setup
|
|
|
|
#
|
|
|
|
|
|
|
|
# Ping my server to check network.
|
2021-05-22 10:56:59 +02:00
|
|
|
ping -c 1 kallestruik.nl > /dev/null
|
2021-05-22 10:49:31 +02:00
|
|
|
|
|
|
|
# Check if the ping was successful. If it was not inform the user and exit.
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "[!] You do not seem to have a network connect. Please establish one first."
|
|
|
|
echo ""
|
|
|
|
echo "[?] For wireless networks you can use the 'iwctl' command to establish a connection."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Enable NTP to sync system time.
|
|
|
|
timedatectl set-ntp true
|
|
|
|
|
|
|
|
#
|
|
|
|
# Partitioning
|
|
|
|
#
|
|
|
|
|
|
|
|
echo "+================================+"
|
|
|
|
echo "| Partitioning |"
|
|
|
|
echo "+================================+"
|
|
|
|
|
|
|
|
# Print a list of block devices.
|
|
|
|
lsblk -o NAME,LABEL,HOTPLUG,SIZE,MODEL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "[?] Above is a list of block devices found on the system. Please choose the one that you want to use for this installation."
|
|
|
|
echo "[?] Or enter manual to drop to a shell for manual partitioning."
|
2021-05-22 10:56:59 +02:00
|
|
|
read -p "[/dev/sda,/dev/nvme0n1,manual,etc] " disk_base
|
2021-05-22 10:49:31 +02:00
|
|
|
|
|
|
|
# Check for manual mode and drop them into a shell.
|
|
|
|
if [ $disk_base == "manual" ]; then
|
|
|
|
echo "[?] Make sure to also mount the full file structure under the /mnt directory."
|
|
|
|
echo "[?] Good luck! Type exit to return to the installer."
|
|
|
|
zsh
|
|
|
|
else
|
2021-05-22 10:58:34 +02:00
|
|
|
ls $disk_base > /dev/null
|
|
|
|
|
|
|
|
if [ $? != 0 ]; then
|
2021-05-22 10:49:31 +02:00
|
|
|
echo "[!] Device $disk_base does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure that the user wants to erase the full disk.
|
2021-05-22 10:56:59 +02:00
|
|
|
read -p "[!] This will destroy all data on device $disk_base! Are you sure you want to continue? [y/N] " confirmation
|
2021-05-22 10:49:31 +02:00
|
|
|
|
|
|
|
# If they are not exit.
|
|
|
|
if [ $confirmation != "y" ]; then
|
|
|
|
echo "[?] Goodbye! :)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2021-05-22 10:56:59 +02:00
|
|
|
echo "[?] Creating GPT"
|
2021-05-22 10:49:31 +02:00
|
|
|
# Create a new GPT.
|
|
|
|
parted $disk_base -- mklabel gpt
|
|
|
|
|
|
|
|
# Get the size of swap to use.
|
2021-05-22 10:56:59 +02:00
|
|
|
read -p "[?] How large do you want your swap to be? [GiB] " swap_size
|
2021-05-22 10:49:31 +02:00
|
|
|
|
|
|
|
# Create partitions.
|
|
|
|
echo "[?] Creating partitions."
|
|
|
|
|
|
|
|
# Create the root partition.
|
|
|
|
parted $disk_base -- mkpart primary 512MiB -"$swap_size"GiB
|
|
|
|
|
|
|
|
# Create the swap partition.
|
|
|
|
parted $disk_base -- mkpart primary linux-swap -"$swap_size"GiB 100%
|
|
|
|
|
|
|
|
# Create the EFI partition.
|
|
|
|
parted $disk_base -- mkpart ESP fat32 1MiB 512MiB
|
|
|
|
parted $disk_base -- set 3 esp on
|
|
|
|
|
|
|
|
# Get the partition prefix from the user.
|
|
|
|
echo "[?] What prefix should be used for partitions? For HDDs and SATA SSDs this is probably the same as the device you selected earlier."
|
|
|
|
echo "[?] For nvme SSDs it will most likely be something like /dev/nvme0n1p"
|
2021-05-22 10:56:59 +02:00
|
|
|
read -p "[?] " partition_base
|
2021-05-22 10:49:31 +02:00
|
|
|
|
|
|
|
# Create filesystems.
|
|
|
|
echo "[?] Creating file systems. This might take a while."
|
|
|
|
|
|
|
|
# Create root filesystem.
|
|
|
|
mkfs.ext4 -L Arch "$partition_base"1
|
|
|
|
# Create swap.
|
|
|
|
mkswap -L swap "$partition_base"2
|
|
|
|
# Create EFI filesystem.
|
|
|
|
mkfs.fat -F 32 -n boot "$partition_base"3
|
|
|
|
|
|
|
|
# Mount filesystems.
|
|
|
|
mount "$partition_base"1 /mnt
|
|
|
|
mkdir -p /mnt/boot
|
|
|
|
mount "$partition_base"3 /mnt/boot
|
|
|
|
|
|
|
|
# And turn on swap
|
|
|
|
swapon "$partition_base"2
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Package installation
|
|
|
|
#
|
|
|
|
|
|
|
|
echo "[?] Installing packages using pacstrap. This will take quite a bit of time."
|
|
|
|
echo "[?] Go get a cup of thee or something."
|
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
# Use pacstrap to install all packages from the packages file.
|
2021-05-23 12:13:38 +02:00
|
|
|
pacstrap /mnt `cat packages`
|
2021-05-22 10:49:31 +02:00
|
|
|
|
|
|
|
echo "[?] Package installation done. Generating /etc/fstab now."
|
|
|
|
|
|
|
|
# Generate fstab.
|
|
|
|
genfstab -U /mnt >> /mnt/etc/fstab
|
|
|
|
|
2021-05-23 12:13:38 +02:00
|
|
|
#
|
|
|
|
# Chroot part
|
|
|
|
#
|
|
|
|
echo "[?] Package installation is done. Please enter a couple bits of information about your system."
|
2021-05-23 12:18:19 +02:00
|
|
|
read -p "What timezone? [Europe/Amsterdam] " time_zone
|
|
|
|
read -p "What locale? [en_US.UTF-8] " locale
|
|
|
|
read -p "What hostname? [arch] " hostname
|
|
|
|
read -p "What cpu vendor? [intel/amd]" cpu_vendor
|
2021-05-23 12:13:38 +02:00
|
|
|
|
|
|
|
echo "[?] Starting work in chroot now."
|
|
|
|
echo "
|
|
|
|
ln -sf /usr/share/zoneinfo/$time_zone /etc/localtime
|
|
|
|
hwclock --systohc
|
|
|
|
echo \"$locale UTF-8\" > /etc/locale.gen
|
|
|
|
locale-gen
|
|
|
|
echo \"LANG=$locale\" > /etc/locale.conf
|
|
|
|
echo \"$hostname\" > /etc/hostname
|
|
|
|
echo \"127.0.0.1 localhost
|
|
|
|
::1 localhost
|
|
|
|
127.0.1.1 $hostname\" > /etc/hosts
|
|
|
|
echo \"[!] Please set your root password below\"
|
|
|
|
passwd
|
|
|
|
bootctl install
|
|
|
|
mkdir -p /etc/pacman.d/hooks/
|
|
|
|
echo \"[Trigger]
|
|
|
|
Type = Package
|
|
|
|
Operation = Upgrade
|
|
|
|
Target = systemd
|
|
|
|
|
|
|
|
[Action]
|
|
|
|
Description = Updating systemd-boot
|
|
|
|
When = PostTransaction
|
|
|
|
Exec = /usr/bin/bootctl update\" > /etc/pacman.d/hooks/100-systemd-boot.hook
|
|
|
|
pacman -Sy \"$cpu_vendor\"-ucode
|
|
|
|
" > arch-chroot /mnt
|