blob: 526eeb7c8567a85aca64a71a147fa760dc6aa7d5 (
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
|
#!/bin/sh
if [ $(id -u) -ne 0 ]
then echo "Please run as root"
exit
fi
export SCRIPTPATH=$(dirname "$(readlink -f "$0")")
if [ -z $1 ]; then
echo "Which drive?"
read DRIVE
else
export DRIVE=$1
fi
export BASE=$(basename $DRIVE)
export PART="/dev/$(basename $(echo /sys/class/block/$BASE/$BASE* | \
xargs -n1 echo | sed 1q | rev | cut -c 2- | rev ))"
# Assumes there is SOME partitioning
# List all partitions of device, get first one, remove last char.
umount $DRIVE*
if [ ! -e installed ]; then
parted -s $DRIVE -- mklabel gpt
parted -s $DRIVE -- mkpart fat32 0 512M
parted -s $DRIVE -- set 1 esp on
parted -s $DRIVE -- mkpart ext4 512M -30G
parted -s $DRIVE -- mkpart ntfs -30G -0
yes | mkfs.vfat ${PART}1
yes | mkfs.ntfs ${PART}3
cryptsetup luksFormat ${PART}2
cryptsetup open ${PART}2 cryptlvm
pvcreate /dev/mapper/cryptlvm
vgcreate Crypt /dev/mapper/cryptlvm
lvcreate -L 16G Crypt -n swap
mkswap /dev/Crypt/swap
lvcreate -L 32G Crypt -n root
mkfs.ext4 /dev/Crypt/root
mount /dev/Crypt/root /mnt
mkdir /mnt/boot
mount ${PART}1 /mnt/boot
swapon /dev/Crypt/swap
pacstrap /mnt base || exit 1
genfstab -U /mnt >> /mnt/etc/fstab
sed "s|%%UUID%%|$(blkid -o value -s UUID ${PART}2)|" src/etc/default/grub.orig > src/etc/default/grub
touch installed
else
cryptsetup open ${PART}2 cryptlvm
mount /dev/Crypt/root /mnt
mount ${PART}1 /mnt/boot
fi
mkdir -pv /mnt/root/dotfiles
cp -r . /mnt/root/dotfiles
arch-chroot /mnt << EOF
sh /root/dotfiles/build.sh
EOF
echo "DONE! You should set passwords, move around ssh keys, etc."
|