#!/bin/bash set -eux if ! timeout 1 curl -Is tombarrett.xyz | grep "200 OK" > /dev/null; then echo "Please first connect to the internet." exit fi if ! test -b "${1:-}"; then echo "Please pass an existing drive as an argument. ie /dev/sda" exit fi if [ -z "${2:-}" ]; then echo "Please pass a hostname also as the second argument." exit fi parted -s "$1" mklabel gpt if ! test -e "/sys/firmware/efi/efivars"; then BOOT_DIR="$1"2 ROOT_DIR="$1"3 parted -s "$1" mkpart grub 0% 1MiB parted -s "$1" set 1 bios_grub on parted -s "$1" mkpart grubcfg 1MiB 513MiB mkfs.ext4 "$BOOT_DIR" parted -s "$1" mkpart root 513MiB 100% else BOOT_DIR="$1"1 ROOT_DIR="$1"2 parted -s "$1" mkpart efi fat32 0% 513MiB mkfs.fat -F 32 "$BOOT_DIR" parted -s "$1" set 1 boot on parted -s "$1" mkpart home ext4 513MiB 100% fi cryptsetup luksFormat "$ROOT_DIR" cryptsetup open "$ROOT_DIR" root mkfs.ext4 /dev/mapper/root mount /dev/mapper/root /mnt mkdir -p /mnt/boot/ mount "$BOOT_DIR" /mnt/boot timedatectl set-ntp true rm -rf /etc/pacman.d/gnupg/ pacman-key --init pacman-key --populate pacstrap /mnt base linux linux-firmware git vim grub efibootmgr arch-install-scripts networkmanager cp /root/.loader /mnt/root/loader UUID=$(lsblk --output UUID,PATH | grep "$ROOT_DIR" | cut -f 1 -d ' ') arch-chroot /mnt /root/loader "$1" "$2" "$UUID"