aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig17
-rw-r--r--README.md8
-rw-r--r--mirrorlist.ranked8
-rw-r--r--mirrorlist.unranked71
-rw-r--r--root/bootloader/grub-bios.sh18
-rw-r--r--root/bootloader/grub-efi.sh21
-rwxr-xr-xroot/chroot.sh111
-rw-r--r--root/disklayout/bios-gpt.sh31
-rw-r--r--root/disklayout/bios-msdos.sh28
-rw-r--r--root/disklayout/mode.sh44
-rw-r--r--root/fixefi.sh20
-rwxr-xr-xroot/install.sh61
-rwxr-xr-xroot/iskra.sh135
-rwxr-xr-xrun.sh27
-rwxr-xr-xzazheg.sh34
15 files changed, 488 insertions, 146 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..636d5c8
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,17 @@
+# EditorConfig is awesome: https://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+indent_style = space
+indent_size = 2
+max_line_length = 100
+
+# Tab indentation (no size specified)
+[Makefile]
+indent_style = tab
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c39f3d8
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+# Automated arch installs
+
+zazheg and iskra (Russian, blown spark or lit spark) are a pair of scripts intended to help automate
+provisioning Archlinux hosts.
+
+The basic idea is that you (either with a customized boot image or hand-configuration) enable SSHD
+on a live booted host, and this script pair will do the rest in terms of formatting the host's
+disk(s) and bootstrapping a viable host installation.
diff --git a/mirrorlist.ranked b/mirrorlist.ranked
new file mode 100644
index 0000000..9b7f4f1
--- /dev/null
+++ b/mirrorlist.ranked
@@ -0,0 +1,8 @@
+# Server list generated by rankmirrors on 2018-06-09
+# United States
+Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
+Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
+Server = https://archlinux.us-west.mirror.zoidplex.net/$repo/os/$arch
+Server = http://mirror.lty.me/archlinux/$repo/os/$arch
+Server = https://mirrors.sonic.net/archlinux/$repo/os/$arch
+Server = http://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch
diff --git a/mirrorlist.unranked b/mirrorlist.unranked
new file mode 100644
index 0000000..6f82304
--- /dev/null
+++ b/mirrorlist.unranked
@@ -0,0 +1,71 @@
+# United States
+Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
+Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch
+Server = http://mirrors.aggregate.org/archlinux/$repo/os/$arch
+Server = http://ca.us.mirror.archlinux-br.org/$repo/os/$arch
+Server = http://il.us.mirror.archlinux-br.org/$repo/os/$arch
+Server = http://archlinux.surlyjake.com/archlinux/$repo/os/$arch
+Server = https://archlinux.surlyjake.com/archlinux/$repo/os/$arch
+Server = http://arlm.tyzoid.com/$repo/os/$arch
+Server = https://arlm.tyzoid.com/$repo/os/$arch
+Server = http://mirror.as65535.net/archlinux/$repo/os/$arch
+Server = http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch
+Server = http://mirror.cc.columbia.edu/pub/linux/archlinux/$repo/os/$arch
+Server = http://centos.mbni.med.umich.edu/archlinux/$repo/os/$arch
+Server = http://arch.mirror.constant.com/$repo/os/$arch
+Server = https://arch.mirror.constant.com/$repo/os/$arch
+Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
+Server = http://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/$arch
+Server = http://distro.ibiblio.org/archlinux/$repo/os/$arch
+Server = http://mirror.epiphyte.network/archlinux/$repo/os/$arch
+Server = https://mirror.epiphyte.network/archlinux/$repo/os/$arch
+Server = http://mirror.es.its.nyu.edu/archlinux/$repo/os/$arch
+Server = http://mirrors.gigenet.com/archlinux/$repo/os/$arch
+Server = http://mirror.grig.io/archlinux/$repo/os/$arch
+Server = https://mirror.grig.io/archlinux/$repo/os/$arch
+Server = http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch
+Server = http://mirror.hackingand.coffee/arch/$repo/os/$arch
+Server = https://mirror.hackingand.coffee/arch/$repo/os/$arch
+Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
+Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
+Server = http://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch
+Server = http://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch
+Server = http://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch
+Server = https://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch
+Server = https://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch
+Server = https://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch
+Server = http://mirrors.liquidweb.com/archlinux/$repo/os/$arch
+Server = http://mirror.lty.me/archlinux/$repo/os/$arch
+Server = https://mirror.lty.me/archlinux/$repo/os/$arch
+Server = http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
+Server = https://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
+Server = http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch
+Server = http://mirror.metrocast.net/archlinux/$repo/os/$arch
+Server = http://mirror.kaminski.io/archlinux/$repo/os/$arch
+Server = https://mirror.kaminski.io/archlinux/$repo/os/$arch
+Server = http://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
+Server = https://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
+Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
+Server = http://arch.mirrors.pair.com/$repo/os/$arch
+Server = http://mirrors.rit.edu/archlinux/$repo/os/$arch
+Server = https://mirrors.rit.edu/archlinux/$repo/os/$arch
+Server = http://mirrors.rutgers.edu/archlinux/$repo/os/$arch
+Server = https://mirrors.rutgers.edu/archlinux/$repo/os/$arch
+Server = http://mirrors.sonic.net/archlinux/$repo/os/$arch
+Server = https://mirrors.sonic.net/archlinux/$repo/os/$arch
+Server = http://mirrors.sorengard.com/archlinux/$repo/os/$arch
+Server = https://mirrors.sorengard.com/archlinux/$repo/os/$arch
+Server = http://arch.mirror.square-r00t.net/$repo/os/$arch
+Server = https://arch.mirror.square-r00t.net/$repo/os/$arch
+Server = http://mirror.stephen304.com/archlinux/$repo/os/$arch
+Server = https://mirror.stephen304.com/archlinux/$repo/os/$arch
+Server = http://mirror.umd.edu/archlinux/$repo/os/$arch
+Server = http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch
+Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch
+Server = http://mirror.yellowfiber.net/archlinux/$repo/os/$arch
+Server = http://archlinux.us-central.mirror.zoidplex.net/$repo/os/$arch
+Server = http://archlinux.us-east.mirror.zoidplex.net/$repo/os/$arch
+Server = http://archlinux.us-west.mirror.zoidplex.net/$repo/os/$arch
+Server = https://archlinux.us-central.mirror.zoidplex.net/$repo/os/$arch
+Server = https://archlinux.us-east.mirror.zoidplex.net/$repo/os/$arch
+Server = https://archlinux.us-west.mirror.zoidplex.net/$repo/os/$arch
diff --git a/root/bootloader/grub-bios.sh b/root/bootloader/grub-bios.sh
new file mode 100644
index 0000000..623245e
--- /dev/null
+++ b/root/bootloader/grub-bios.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+set -exuo pipefail
+
+function _bootloader_init() {
+ # Require packages in
+ pacstrap_require grub
+}
+
+function _bootloader_check() {
+ # Do any validation
+ true
+}
+
+function _bootloader_apply() {
+ # $1 is the target boot device
+ grub-install --target=i386-pc --recheck "$1"
+ grub-mkconfig -o /boot/grub/grub.cfg
+}
diff --git a/root/bootloader/grub-efi.sh b/root/bootloader/grub-efi.sh
new file mode 100644
index 0000000..b6b3b04
--- /dev/null
+++ b/root/bootloader/grub-efi.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+set -exuo pipefail
+
+function _bootloader_init() {
+ # Require packages in
+ pacstrap_require grub
+}
+
+function _bootloader_check() {
+ # Do any validation
+ true
+}
+
+function _bootloader_apply() {
+ # $1 is the target boot device
+ grub-install --target=x86_64-efi \
+ --efi-directory=/boot/efi/ \
+ --bootloader-id=GRUB \
+ --recheck "$1"
+ grub-mkconfig -o /boot/grub/grub.cfg
+}
diff --git a/root/chroot.sh b/root/chroot.sh
index 087d928..c29105c 100755
--- a/root/chroot.sh
+++ b/root/chroot.sh
@@ -1,67 +1,62 @@
-#!/bin/bash
+#!/usr/bin/env bash
+set -exuo pipefail
-set -x
+function _userland_init() {
+ pacstrap_require sudo ansible openssh
+}
-# $1 to this script is the boot device's name
-# $2 is the hostname to deploy
+function _userland_check() {
+ true
+}
-HOST="$2"
-USERNAME=arrdem
-HOME_DIR="/home/${USERNAME}"
+function _userland_apply() {
+ eval "$@" # Inline environment variables
-# grub as a bootloader
-grub-install --target=x86_64-efi --efi-directory=/boot/efi/ --bootloader-id=GRUB --recheck "$1"
-
-# This makes the grub timeout 0, it's faster than 5 :)
-#
-# Skipping this so that it's still possible to physically get on the
-# node without using custom boot media.
-# sudo sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/g' /etc/default/grub
-
-grub-mkconfig -o /boot/grub/grub.cfg
-
-# run these following essential service by default
-systemctl enable sshd.service
-systemctl enable dhcpcd.service
-systemctl enable ntpd.service
-
-# Network configuration
-echo "$HOST.apartment.arrdem.com" > /etc/hostname
-cat <<EOF >> /etc/hosts
+ ## Set up the hostname
+ echo "$HOSTNAME" > /etc/hostname
+ cat <<EOF > /etc/hosts
127.0.0.1 localhost
::1 localhost
-127.0.1.1 $HOSTNAME $HOSTNAME.apartment.arrdem.com
+127.0.1.1 $(echo $HOSTNAME | awk -F'.' '{print $1}') $HOSTNAME
EOF
-# adding your normal user with additional wheel group so can sudo
-useradd -m -G wheel -s /bin/bash "$USERNAME"
-
-# adding public key both to root and user for ssh key access
-mkdir -m 700 -p "$HOME_DIR/.ssh"
-mkdir -m 700 -p /root/.ssh
-cp /authorized_keys "/$HOME_DIR/.ssh"
-cp /authorized_keys /root/.ssh
-chown -R "$USERNAME:$USERNAME" "$HOME_DIR/.ssh"
-
-# adjust your timezone here
-ln -f -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
-hwclock --systohc
-
-# adjust your name servers here if you don't want to use google
-# echo 'name_servers="8.8.8.8 8.8.4.4"' >> /etc/resolvconf.conf
-
-# Set up the locale
-echo en_US.UTF-8 UTF-8 > /etc/locale.gen
-echo LANG=en_US.UTF-8 > /etc/locale.conf
-locale-gen
-
-# because we are using ssh keys, make sudo not ask for passwords
-echo 'root ALL=(ALL) ALL' > /etc/sudoers
-echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
-
-# I like to use vim :)
-echo -e 'EDITOR=emacs' > /etc/environment
+ ## Set up the network
+ systemctl enable systemd-networkd.service # provided by systemd
+ systemctl enable systemd-resolved.service
+ # Some jank to configure all wired interfaces to DHCP
+ for if in $(ip addr | awk -F': ' '/(en|if|eth)[a-z0-9]*:/ {print $2;}'); do
+ cat <<EOF > /etc/systemd/network/20-$if.network
+[Match]
+Name=$if
+
+[Network]
+DHCP=yes
+EOF
+ done
+
+ ## Set up the clock
+ systemctl enable systemd-timesyncd.service # provided by systemd
+ timedatectl set-ntp true
+ ln -f -s /usr/share/zoneinfo/UTC /etc/localtime
+ hwclock --systohc
+ timedatectl timesync-status
+
+ ## Set up the locale (UTF-8)
+ echo en_US.UTF-8 UTF-8 > /etc/locale.gen
+ echo LANG=en_US.UTF-8 > /etc/locale.conf
+ locale-gen
+
+ ## Set up SSH(D)
+ systemctl enable sshd.service # provided by OpenSSH
+ # (Re)Configure to allow root login
+ sed -i 's/[#]?PermitRootLogin.*/PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config
+ mkdir -p /root/.ssh
+ # Obviously anyone else will want to change this...
+ cat <<EOF >> /root/.ssh/authorized_keys
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFmDJaEDD9/mQc5KcboPe2IX0riA4pMKrvD12JVmT98A root@tirefireind.us
+EOF
-# auto-complete these essential commands
-echo complete -cf sudo >> /etc/bash.bashrc
-echo complete -cf man >> /etc/bash.bashrc
+ ## And install a root password just in case
+ # Obviously anyone else will want to change this...
+ sed -i 's!root.*!root:$6$UizQ2ukInflP0txb$nKxCbkERluzmajDKkza/GERPhKoZWmP/Hs4drl2Ij4EAV3gvScQrz.ksWDILnvc/veVQLogmJdfsrMlZNB.7C.:18455::::::!1' /etc/shadow
+}
diff --git a/root/disklayout/bios-gpt.sh b/root/disklayout/bios-gpt.sh
new file mode 100644
index 0000000..c898de8
--- /dev/null
+++ b/root/disklayout/bios-gpt.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+set -exuo pipefail
+
+# Applies a traditional single disk BIOS boot layout.
+# Could be used as the basis for simple boot layouts with additional data disks.
+
+function _disklayout_check() {
+ true
+}
+
+function _disklayout_apply() {
+ ROOT_DISK="$1"
+ boot_size=1024
+ ROOT_PARTITION="${ROOT_DISK}2"
+
+ ## Partitioning
+ parted -s "${ROOT_DISK}" mklabel gpt
+ parted -s "${ROOT_DISK}" mkpart primary 0 256Mib
+ parted -s "${ROOT_DISK}" set 1 bios_grub on
+ parted -s "${ROOT_DISK}" mkpart primary ext4 256Mib 100%
+
+ ## Ensure changes applied
+ sync
+
+ ## Formatting
+ # Note that p1 is the BIOS boot partition, which need not be formatted
+ mkfs.ext4 -F "${ROOT_PARTITION}"
+
+ ## Mount
+ mount "${ROOT_PARTITION}" /mnt
+}
diff --git a/root/disklayout/bios-msdos.sh b/root/disklayout/bios-msdos.sh
new file mode 100644
index 0000000..de916b1
--- /dev/null
+++ b/root/disklayout/bios-msdos.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+set -exuo pipefail
+
+# Applies a traditional single disk BIOS boot layout.
+# Could be used as the basis for simple boot layouts with additional data disks.
+
+function _disklayout_check() {
+ true
+}
+
+function _disklayout_apply() {
+ ROOT_DISK="$1"
+ ROOT_PARTITION="${ROOT_DISK}1"
+
+ ## Partitioning
+ parted -s "${ROOT_DISK}" mklabel msdos
+ parted -s "${ROOT_DISK}" mkpart primary ext4 0Mib 100%
+ parted -s "${ROOT_DISK}" set 1 boot on
+
+ ## Ensure changes applied
+ sync
+
+ ## Formatting
+ mkfs.ext4 -F "${ROOT_PARTITION}"
+
+ ## Mount
+ mount "${ROOT_PARTITION}" /mnt
+}
diff --git a/root/disklayout/mode.sh b/root/disklayout/mode.sh
new file mode 100644
index 0000000..aef8404
--- /dev/null
+++ b/root/disklayout/mode.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+set -exuo pipefail
+
+function _disklayout_check() {
+ true
+}
+
+function _disklayout_apply() {
+ # Partition the NVME device as the boot device
+ BOOT_DISK="$1"
+ # Size (in MB) for the EIF boot partition
+ boot_size=1024
+ BOOT_PARTITION="${BOOT_DISK}p1"
+ ROOT_PARTITION="${BOOT_DISK}p2"
+
+ # This disk layout also has a data disk
+ DATA_DISK="/dev/sda"
+ DATA_PARTITION="${DATA_DISK}1" # NVME and SATA have different naming schemes >.>
+
+ ## Partition
+ parted -s "$BOOT_DISK" mklabel gpt
+ parted -s -a optimal "$BOOT_DISK" mkpart primary fat32 0 "$(( 1 + ${boot_size} ))"Mib
+ parted -s "$BOOT_DISK" set 1 boot on
+ parted -s "$BOOT_DISK" set 1 esp on
+ parted -s -a optimal "$BOOT_DISK" mkpart primary ext4 "$(( 1 + ${boot_size} ))"Mib 100%
+
+ parted -s "$DATA_DISK" mklabel gpt
+ parted -s -a optimal "$DATA_DISK" mkpart primary ext4 0% 100%
+
+ ## Ensure changes applied
+ sync
+
+ ## Formatting
+ mkfs.fat -F32 "$BOOT_PARTITION"
+ mkfs.ext4 -F "$ROOT_PARTITION"
+ mkfs.ext4 -F "$DATA_PARTITION"
+
+ ## Mount
+ mount "$ROOT_PARTITION" /mnt
+ mkdir -p /mnt/boot/efi
+ mount "$BOOT_PARTITION" /mnt/boot/efi
+ mkdir -p /mnt/data
+ mount "$DATA_PARTITION" /mnt/data
+}
diff --git a/root/fixefi.sh b/root/fixefi.sh
new file mode 100644
index 0000000..18da3f5
--- /dev/null
+++ b/root/fixefi.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+set -ex
+
+# $1 to this script is the boot device's name
+# $2 is the hostname to deploy
+
+# grub as a bootloader
+grub-install --target=x86_64-efi \
+ --efi-directory=/boot/efi/ \
+ --bootloader-id=GRUB \
+ --recheck "$1"
+
+# This makes the grub timeout 0, it's faster than 5 :)
+#
+# Skipping this so that it's still possible to physically get on the
+# node without using custom boot media.
+# sudo sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/g' /etc/default/grub
+
+grub-mkconfig -o /boot/grub/grub.cfg
diff --git a/root/install.sh b/root/install.sh
deleted file mode 100755
index c53ad67..0000000
--- a/root/install.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-
-set -x
-
-# $1 is the hostname to install
-
-HOSTNAME="$1"
-
-# Partition the NVME device as the boot device
-BOOT_DISK="/dev/nvme0n1"
-parted -s "$BOOT_DISK" mklabel gpt
-
-BOOT_PARTITION="${BOOT_DISK}p1"
-parted -s -a optimal "$BOOT_DISK" mkpart primary 0 512
-parted -s "$BOOT_DISK" set 1 boot on
-parted -s "$BOOT_DISK" set 1 esp on
-# Make fat32
-mkfs.fat -F32 "$BOOT_PARTITION"
-
-ROOT_PARTITION="${BOOT_DISK}p2"
-parted -s -a optimal "$BOOT_DISK" mkpart primary ext4 512 100%
-# Force creation
-mkfs.ext4 -F "$ROOT_PARTITION"
-
-# Partition the data/scratch disk
-DATA_DISK="/dev/sda"
-DATA_PARTITION="${DATA_DISK}1" # NVME and SATA have different naming schemes >.>
-parted -s "$DATA_DISK" mklabel gpt
-parted -s -a optimal "$DATA_DISK" mkpart primary ext4 0% 100%
-# Force creation
-mkfs.ext4 -F "$DATA_PARTITION" # I may regret this later
-
-# Mount the boot partition - we'll chroot into it in a second
-mount "$ROOT_PARTITION" /mnt
-
-mkdir -p /mnt/boot/efi
-mount "$BOOT_PARTITION" /mnt/boot/efi
-
-mkdir /mnt/data
-mount "$DATA_PARTITION" /mnt/data
-
-mkdir -p /mnt/root/.ssh
-
-# Bootstrap into the new disk & install a bunch of stuff
-pacman -Syy
-pacstrap /mnt base base-devel grub efibootmgr openssh sudo ntp wget vim emacs-nox
-genfstab -p /mnt >> /mnt/etc/fstab
-
-cp ./chroot.sh /mnt/
-cp ~/.ssh/authorized_keys /mnt/
-cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
-
-# Chroot into the new disk and run the chroot part of this setup dance
-arch-chroot /mnt /chroot.sh "$BOOT_DISK" "$HOSTNAME"
-
-# Remove the chroot bits
-rm /mnt/chroot.sh
-rm /mnt/authorized_keys
-
-umount -R /mnt
-systemctl reboot
diff --git a/root/iskra.sh b/root/iskra.sh
new file mode 100755
index 0000000..d475473
--- /dev/null
+++ b/root/iskra.sh
@@ -0,0 +1,135 @@
+#!/usr/bin/env bash
+set -exuo pipefail
+
+# 'the spark'
+#
+# Entry point used to drive applying host config from a variety of scripts.
+
+# BASH 'prelude'
+fn_exists() {
+ [ `type -t $1`"" == 'function' ]
+}
+
+# Packages which will be installed into the chroot
+export BOOTSTRAP_PACKAGES=(linux linux-firmware base curl emacs-nox rxvt-unicode-terminfo)
+
+function pacstrap_require() {
+ # Require a package be present after pacstrapping
+ BOOTSTRAP_PACKAGES+=("${@}")
+}
+
+# Required
+export BOOT_DEVICE="$1"
+shift
+if ! [[ "${BOOT_DEVICE}" =~ ^/dev* ]]; then
+ echo "Fatal: Usagea error. Expected boot device path, got ${BOOT_DEVICE}"
+ exit -1
+elif ! stat "${BOOT_DEVICE}"; then
+ echo "Fatal: Boot device ${BOOT_DEVICE} was specified but does not exist!"
+ exit -1
+fi
+
+# Diskloader & preconditions
+export DISKLAYOUT_PROGN="$1"
+shift
+if [ -z "${DISKLAYOUT_PROGN}" ]; then
+ echo "Fatal: No disklayout script provided"
+ exit -1
+elif ! source "${DISKLAYOUT_PROGN}"; then
+ echo "Fatal: Failed to load disklayout script ${DISKLAYOUT_PROGN}"
+ exit -1
+else
+ if fn_exists _disklayout_init; then
+ _disklayout_init;
+ fi
+ if fn_exists _disklayout_check; then
+ _disklayout_check
+ else
+ echo "Warning: disklayout script ${DISKLAYOUT_PROGN} did not register preconditions, ignoring"
+ fi
+
+ if ! fn_exists _disklayout_apply; then
+ echo "Fatal: disklayout script ${DISKLAYOUT_PROGN} did not register an entry point"
+ fi
+fi
+
+# Bootloader & preconditions
+export BOOTLOADER_PROGN="$1"
+shift
+if [ -z "${BOOTLOADER_PROGN}" ]; then
+ echo "Fatal: No bootloader script provided"
+ exit -1
+elif ! source "${BOOTLOADER_PROGN}"; then
+ echo "Fatal: Failed to load bootloader script ${BOOTLOADER_PROGN}"
+ exit -1
+else
+ if fn_exists _bootloader_init; then
+ _bootloader_init;
+ fi
+ if fn_exists _bootloader_check; then
+ _bootloader_check
+ else
+ echo "Warning: bootloader script ${BOOTLOADER_PROGN} did not register preconditions, ignoring"
+ fi
+
+ if ! fn_exists _bootloader_apply; then
+ echo "Fatal: bootloader script ${BOOTLOADER_PROGN} did not register an entry point"
+ fi
+fi
+
+# Userland & preconditions
+export USERLAND_PROGN="$1"
+shift
+if [ -z "${USERLAND_PROGN}" ]; then
+ echo "Warning: no userland configuration provided, ignoring"
+elif ! source "${USERLAND_PROGN}"; then
+ echo "Fatal: Failed to load userland script ${USERLAND_PROGN}"
+ exit -1
+else
+ if fn_exists _userland_init; then
+ _userland_init;
+ fi
+ if fn_exists _userland_check; then
+ _userland_check
+ else
+ echo "Warning: userland script ${USERLAND_PROGN} did not register preconditions"
+ fi
+
+ if ! fn_exists _userland_apply; then
+ echo "Fatal: userland script ${USERLAND_PROGN} did not register an entry point"
+ fi
+fi
+
+# Export everything so when we subshell (eg. arch-chroot) everything works transparently
+eval "$(declare -F | sed -e 's/-f /-fx /')"
+
+# Update the live medium first, just in case
+pacman --noconfirm --needed -Sy archlinux-keyring
+
+## Apply foundational configuration
+# Try to apply the disk layout
+_disklayout_apply "${BOOT_DEVICE}"
+
+# And make sure it was sane
+if ! grep -e " /mnt " /etc/mtab; then
+ echo "Fatal: disklayout script failed to mount a new / to /mnt!"
+ exit -1
+fi
+
+# Bootstrap the new / with a 'minimal' Arch install
+pacstrap /mnt "${BOOTSTRAP_PACKAGES[@]}"
+
+# And save the current /mnt based mounts to a new fstab
+genfstab -U -p /mnt >> /mnt/etc/fstab
+
+# Chroot into the new disk and do whatever the bootloader needs
+arch-chroot /mnt /bin/bash -c "set -exuo pipefail;_bootloader_apply ${BOOT_DEVICE}"
+
+# Chroot into the new disk and do any userland setup
+if fn_exists _userland_apply; then
+ arch-chroot /mnt /bin/bash -c "set -exuo pipefail;_userland_apply ${@}"
+fi
+
+# Reboot the system
+umount -R /mnt
+systemctl reboot
diff --git a/run.sh b/run.sh
deleted file mode 100755
index 09b4a6f..0000000
--- a/run.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-read HOSTNAME
-read HOST
-PORT=22
-
-echo PORT="$PORT", HOST="$HOST"
-HOST_ROOT="root@$HOST"
-PUBKEY=$(cat ~/.ssh/id_rsa.pub)
-
-if [ ! -f mirrorlist.ranked ]; then
- awk '/^## United States$/{f=1}f==0{next}/^$/{exit}{print substr($0, 2)}' /etc/pacman.d/mirrorlist.pacnew > mirrorlist.unranked
- rankmirrors -n 6 mirrorlist > mirrorlist.ranked
-fi
-
-# copy your public key, so can ssh without a password later on
-ssh -tt -p "$PORT" "$HOST_ROOT" "mkdir -p -m 700 ~/.ssh; echo $PUBKEY > ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys"
-
-# copy install scripts from ./root folder
-scp -P "$PORT" ./root/* "$HOST_ROOT:/root"
-scp -P "$PORT" mirrorlist.ranked "$HOST_ROOT:/etc/pacman.d/mirrorlist"
-
-# set the executable bits
-ssh -tt -p "$PORT" "$HOST_ROOT" "chmod +x ./install.sh ./chroot.sh"
-
-# run the install script remotely
-ssh -tt -p "$PORT" "$HOST_ROOT" "./install.sh" "$HOSTNAME"
diff --git a/zazheg.sh b/zazheg.sh
new file mode 100755
index 0000000..6186ba1
--- /dev/null
+++ b/zazheg.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+set -ex
+
+read HOSTNAME
+read HOST
+PORT=22
+read PUBKEY
+
+echo PORT="${PORT}", HOST="${HOST}", PUBKEY="${PUBKEY}"
+HOST_ROOT="root@${HOST}"
+PUBKEY=$(cat "${PUBKEY}")
+
+if [ ! -f mirrorlist.ranked ]; then
+ awk '/^## United States$/{f=1}f==0{next}/^$/{exit}{print substr($0, 2)}' /etc/pacman.d/mirrorlist.pacnew > mirrorlist.unranked
+ rankmirrors -n 6 mirrorlist.unranked > mirrorlist.ranked
+fi
+
+# Kill off any known host entry
+sed -i "/$HOST/d" ~/.ssh/known_hosts
+
+# copy your public key, so can ssh without a password later on
+ssh -o StrictHostKeyChecking=no -tt -p "${PORT}" "${HOST_ROOT}" "mkdir -p -m 700 ~/.ssh; echo ${PUBKEY} > ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys"
+
+# copy install scripts from ./root folder
+scp -o StrictHostKeyChecking=no -P "${PORT}" -rv ./root/* "${HOST_ROOT}:/root"
+scp -o StrictHostKeyChecking=no -P "${PORT}" mirrorlist.ranked "${HOST_ROOT}:/etc/pacman.d/mirrorlist"
+
+## run the install script remotely
+# ssh -o StrictHostKeyChecking=no -tt -p "${PORT}" "${HOST_ROOT}" "/bin/bash iskra.sh /dev/nvme0n1 disklayout/mode.sh bootloader/grub-efi.sh chroot.sh ${HOSTNAME}"
+ssh -o StrictHostKeyChecking=no -tt -p "${PORT}" "${HOST_ROOT}" "/bin/bash iskra.sh /dev/sda disklayout/trivial-gpt.sh bootloader/grub-bios.sh chroot.sh HOSTNAME=${HOSTNAME}"
+
+## run the efi fix remotely
+# ssh -o StrictHostKeyChecking=no -tt -p "${PORT}" "${HOST_ROOT}" "/bin/bash fixefi.sh"