arch-installer/install.sh

156 lines
3.6 KiB
Bash
Raw Normal View History

2021-05-22 10:49:31 +02:00
#!/bin/sh
source ./settings.env
2021-05-22 10:49:31 +02:00
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 "+================================+"
ls $DISK_BASE > /dev/null
2021-05-22 10:49:31 +02:00
if [ $? != 0 ]; then
echo "[!] Device $DISK_BASE does not exist."
exit 1
fi
2021-05-22 10:49:31 +02:00
# Make sure that the user wants to erase the full disk.
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:49:31 +02:00
echo "[?] Creating GPT"
# Create a new GPT.
parted $DISK_BASE -- mklabel gpt
2021-05-22 10:49:31 +02:00
# Create partitions.
echo "[?] Creating partitions."
2021-05-22 10:49:31 +02:00
# Create the root partition.
parted $DISK_BASE -- mkpart primary 512MiB -"$SWAP_SIZE"
2021-05-22 10:49:31 +02:00
# Create the swap partition.
parted $DISK_BASE -- mkpart primary linux-swap -"$SWAP_SIZE" 100%
2021-05-22 10:49:31 +02:00
# Create the EFI partition.
parted $DISK_BASE -- mkpart ESP fat32 1MiB 512MiB
parted $DISK_BASE -- set 3 esp on
2021-05-22 10:49:31 +02:00
# Create filesystems.
echo "[?] Creating file systems. This might take a while."
2021-05-22 10:49:31 +02:00
# 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
2021-05-22 10:49:31 +02:00
# Mount filesystems.
mount "$PARTITION_BASE"1 /mnt
mkdir -p /mnt/boot
mount "$PARTITION_BASE"3 /mnt/boot
2021-05-22 10:49:31 +02:00
# And turn on swap
swapon "$PARTITION_BASE"2
2021-05-22 10:49:31 +02:00
#
# 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 "[?] Starting work in chroot now."
echo "
ln -sf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime
2021-05-23 12:13:38 +02:00
hwclock --systohc
echo \"$LOCALE UTF-8\" > /etc/locale.gen
2021-05-23 12:13:38 +02:00
locale-gen
echo \"LANG=$LOCALE\" > /etc/locale.conf
echo \"$HOSTNAME\" > /etc/hostname
2021-05-23 12:13:38 +02:00
echo \"127.0.0.1 localhost
::1 localhost
127.0.1.1 $HOSTNAME\" > /etc/hosts
2021-05-23 12:13:38 +02:00
echo \"[!] Please set your root password below\"
passwd
2021-10-22 14:41:27 +02:00
$ROOT_PASSWORD
$ROOT_PASSWORD
2021-05-23 12:13:38 +02:00
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
2021-10-22 14:41:27 +02:00
pacman -Sy --noconfirm \"$CPU_VENDOR\"-ucode
echo \"default arch.conf
timeout 4
console-mode max
\" > /boot/loader/loader.conf
echo \"title Arch Linux
2021-10-22 16:24:34 +02:00
linux /vmlinuz-linux-zen
initrd /$CPU_VENDOR-ucode.img
initrd /initramfs-linux-zen.img
2021-10-22 14:41:27 +02:00
options root="LABEL=Arch" rw
\" > /boot/loader/entries/arch.conf
echo \"title Arch Linux (fallback initramfs)
2021-10-22 16:24:34 +02:00
linux /vmlinuz-linux-zen
initrd /$CPU_VENDOR-ucode.img
initrd /initramfs-linux-zen-fallback.img
2021-10-22 14:41:27 +02:00
options root="LABEL=Arch" rw
\" > /boot/loader/entries/arch_fallback.conf
2021-10-22 16:41:46 +02:00
systemctl enable NetworkManager.service
2021-10-22 15:32:15 +02:00
mkinitcpio -P
2021-10-22 14:24:21 +02:00
" | arch-chroot /mnt
2021-10-23 13:33:00 +02:00
2021-10-23 13:44:25 +02:00
if [$ENABLE_LDAP_MODULE]; then
2021-10-23 13:33:00 +02:00
modules/ldap.sh
fi