Skip to content

Instantly share code, notes, and snippets.

@jarpy
Created May 21, 2019 02:27
Show Gist options
  • Save jarpy/51e91951e51368d8636cae81db5e687d to your computer and use it in GitHub Desktop.
Save jarpy/51e91951e51368d8636cae81db5e687d to your computer and use it in GitHub Desktop.
#!/bin/bash
set -xeuo pipefail
function install() {
pacman --sync --noconfirm $@
}
luks_volume_uuid=$(blkid --match-tag UUID --output value /dev/nvme0n1p2)
ping -c1 google.com || dhclient eno1
pacman --sync --refresh
mkdir -p /etc/ssh
for cipher in rsa dsa ecdsa ed25519; do
file="/etc/ssh/ssh_host_${cipher}_key"
[[ -f ${file} ]] || ssh-keygen -f ${file} -N '' -t ${cipher}
done
ps -eo command | grep -q '^/usr/bin/sshd$' || /usr/bin/sshd
install moreutils
awk '/Australia/ {print; getline; print}' /etc/pacman.d/mirrorlist | sponge /etc/pacman.d/mirrorlist
install terminus-font
setfont ter-v32n
if ! (lsblk | grep -q 'root.*crypt /mnt$'); then
cryptsetup open /dev/nvme0n1p2 root
mount /dev/mapper/root /mnt
fi
root_volume_uuid=$(blkid --match-tag UUID --output value /dev/mapper/root)
mount | grep -q '/dev/nvme0n1p1 on /mnt/boot' || mount /dev/nvme0n1p1 /mnt/boot
[[ ! -f /mnt/boot/vmlinuz-linux ]] && pacstrap /mnt
genfstab -U /mnt > /mnt/etc/fstab
echo 'en_AU.UTF-8 UTF-8' > /etc/locale.gen
arch-chroot /mnt locale-gen
echo 'colt' > /mnt/etc/hostname
cat > /mnt/etc/hosts <<EOF
127.0.0.1 localhost
::1 localhost
10.31.225.6 colt.home.jarpy.net colt
EOF
cat > /mnt/etc/mkinitcpio.conf <<EOF
HOOKS=(base udev keyboard autodetect modconf block filesystems encrypt fsck)
EOF
arch-chroot /mnt mkinitcpio -p linux
efibootmgr \
--create \
--disk /dev/nvme0n1 \
--part 1 \
--label "Arch on nvme0n1" \
--loader /vmlinuz-linux \
--unicode "root=/dev/mapper/root rw initrd=\\initramfs-linux.img cryptdevice=UUID=${luks_volume_uuid}:root:allow-discards" \
--verbose
arch-chroot /mnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment