Initial Commit

This commit is contained in:
2022-12-15 20:45:20 -06:00
commit 9a26e723b4
14 changed files with 283 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eux
readonly USERNAME="deploy"
arch-chroot /mnt useradd --create-home --user-group $USERNAME
arch-chroot /mnt bash -c "echo $USERNAME:$USERNAME | chpasswd"
arch-chroot /mnt mkdir -p /etc/sudoers.d
arch-chroot /mnt touch /etc/sudoers.d/99_$USERNAME
arch-chroot /mnt chmod 0440 /etc/sudoers.d/99_$USERNAME
arch-chroot /mnt echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /mnt/etc/sudoers.d/99_$USERNAME

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -eux
systemctl unmask systemd-networkd systemd-resolved
systemctl enable --now systemd-networkd systemd-resolved
ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf
arch-chroot /mnt systemctl unmask systemd-networkd systemd-resolved
arch-chroot /mnt systemctl enable systemd-networkd systemd-resolved
arch-chroot /mnt systemctl enable sshd

6
scripts/finalization.sh Normal file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eux
umount -R /mnt
echo "All done! You should have a freshly baked raw disk image now"

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -eux
genfstab -t PARTUUID -p /mnt > "/mnt/etc/fstab"
# Remove quiet boot
arch-chroot /mnt sed -i 's,GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet",GRUB_CMDLINE_LINUX_DEFAULT="",' /etc/default/grub
arch-chroot /mnt grub-install /dev/vda
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg

11
scripts/install_system.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eux
pacman-key --init
# Install the system
pacstrap -K /mnt base linux linux-firmware rng-tools grub sudo \
openssh ufw git vim python-pip nomad nomad-driver-nspawn
# Clear the cache
arch-chroot /mnt pacman -Scc --noconfirm

23
scripts/partition_disk.sh Normal file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -eux
readonly DISK="/dev/vda"
readonly BOOT="${DISK}2"
readonly ROOT="${DISK}3"
# Wipe the target disk of all partitions and filesystems
sgdisk --zap-all "${DISK}"
dd if=/dev/zero of="${DISK}" bs=512 count=2048
wipefs --all "${DISK}"
# Create /boot (512M) and / (100%)
sgdisk --new=1:0:+1M --typecode=0:ef02 --change-name=0:bios "${DISK}"
sgdisk --new=2:0:+512M --typecode=0:8300 --change-name=0:boot --attributes=0:set:1 "${DISK}"
sgdisk --new=3:0:0 --typecode=0:8300 --change-name=0:root "${DISK}"
mkfs.ext4 -e remount-ro -q -L boot ${BOOT}
mkfs.ext4 -e remount-ro -q ${ROOT}
mount -o noatime "${ROOT}" /mnt
mkdir -p /mnt/boot
mount -o noatime "${BOOT}" /mnt/boot

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -eux
readonly KEYBOARD="us"
readonly ENCODING="UTF-8"
readonly TIMEZONE="US/Central"
readonly LANGUAGE="en_US.${ENCODING}"
export KEYBOARD ENCODING TIMEZONE LANGUAGE
arch-chroot /mnt ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
arch-chroot /mnt sed -i "s/#${LANGUAGE}/${LANGUAGE}/" /etc/locale.gen
arch-chroot /mnt locale-gen
arch-chroot /mnt echo "${LANGUAGE}" > /etc/locale.conf
arch-chroot /mnt echo "KEYMAP=${KEYBOARD}" > /etc/vconsole.conf

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -eux
while read mountp; do
cat /dev/zero | dd of=${mountp}/EMPTY || true
rm -f ${mountp}/EMPTY
done < <(mount -l -t ext4 | awk '{print $3}')
sync