summaryrefslogtreecommitdiff
path: root/airootfs/root/bootstrap
blob: 7e65be7a1d122442870ccf752dddf1196a691bc9 (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
#!/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 -f "/sys/firmware/efi/efivars"; then
    parted "$1" mkpart bios ext4 0% 513MiB
    mkfs.ext4 "$1"1
    parted "$1" set 1 bios_grub on
    parted "$1" mkpart home ext4 513MiB 100%
else
    parted "$1" mkpart efi fat32 0% 513MiB
    mkfs.fat -F 32 "$1"1
    parted "$1" set 1 esp on
    parted "$1" mkpart home ext4 513MiB 100%
fi

mkfs.ext4 "$1"2

mount "$1"2 /mnt
mkdir -p /mnt/boot/efi
mount "$1"1 /mnt/boot/efi

timedatectl set-ntp true

pacman-key --init
pacman-key --populate
pacstrap /mnt base linux linux-firmware git vim grub

genfstab -U /mnt > /mnt/etc/fstab
cp /root/.loader /mnt/root/loader
arch-chroot /mnt /root/loader $1 $2