156 lines
3.6 KiB
Bash
Executable File
156 lines
3.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
source ./settings.env
|
|
|
|
echo "+===============================+"
|
|
echo "| Kalle's Arch Installer Script |"
|
|
echo "+===============================+"
|
|
|
|
#
|
|
# Early setup
|
|
#
|
|
|
|
# Ping my server to check network.
|
|
ping -c 1 kallestruik.nl > /dev/null
|
|
|
|
# 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
|
|
|
|
if [ $? != 0 ]; then
|
|
echo "[!] Device $DISK_BASE does not exist."
|
|
exit 1
|
|
fi
|
|
|
|
# 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
|
|
|
|
# If they are not exit.
|
|
if [ $confirmation != "y" ]; then
|
|
echo "[?] Goodbye! :)"
|
|
exit 0
|
|
fi
|
|
|
|
echo "[?] Creating GPT"
|
|
# Create a new GPT.
|
|
parted $DISK_BASE -- mklabel gpt
|
|
|
|
# Create partitions.
|
|
echo "[?] Creating partitions."
|
|
|
|
# Create the root partition.
|
|
parted $DISK_BASE -- mkpart primary 512MiB -"$SWAP_SIZE"
|
|
|
|
# Create the swap partition.
|
|
parted $DISK_BASE -- mkpart primary linux-swap -"$SWAP_SIZE" 100%
|
|
|
|
# Create the EFI partition.
|
|
parted $DISK_BASE -- mkpart ESP fat32 1MiB 512MiB
|
|
parted $DISK_BASE -- set 3 esp on
|
|
|
|
# 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
|
|
|
|
#
|
|
# 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.
|
|
pacstrap /mnt `cat packages`
|
|
|
|
echo "[?] Package installation done. Generating /etc/fstab now."
|
|
|
|
# Generate fstab.
|
|
genfstab -U /mnt >> /mnt/etc/fstab
|
|
|
|
#
|
|
# Chroot part
|
|
#
|
|
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
|
|
$ROOT_PASSWORD
|
|
$ROOT_PASSWORD
|
|
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 --noconfirm \"$CPU_VENDOR\"-ucode
|
|
echo \"default arch.conf
|
|
timeout 4
|
|
console-mode max
|
|
\" > /boot/loader/loader.conf
|
|
echo \"title Arch Linux
|
|
linux /vmlinuz-linux-zen
|
|
initrd /$CPU_VENDOR-ucode.img
|
|
initrd /initramfs-linux-zen.img
|
|
options root="LABEL=Arch" rw
|
|
\" > /boot/loader/entries/arch.conf
|
|
echo \"title Arch Linux (fallback initramfs)
|
|
linux /vmlinuz-linux-zen
|
|
initrd /$CPU_VENDOR-ucode.img
|
|
initrd /initramfs-linux-zen-fallback.img
|
|
options root="LABEL=Arch" rw
|
|
\" > /boot/loader/entries/arch_fallback.conf
|
|
systemctl enable NetworkManager.service
|
|
mkinitcpio -P
|
|
" | arch-chroot /mnt
|
|
|
|
if [$ENABLE_LDAP_MODULE]; then
|
|
modules/ldap.sh
|
|
fi
|