summaryrefslogtreecommitdiff
path: root/airootfs/root/bootstrap
blob: dcd3d3fa6d388e53d46a816e0b5a13dcd8ccfc5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -e

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
arch-chroot /mnt /root/loader "$1" "$2" "$ROOT_DIR"