From 5f73da826c357b8958b02b0690a444199b2a85c3 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 26 Nov 2025 19:52:14 +0200 Subject: [PATCH] feat(sqmeta): init as first host --- justfile | 30 +++++++++++++ sqmeta/ADDRESS | 1 + sqmeta/IMGBUILD | 66 +++++++++++++++++++++++++++++ sqmeta/files/etc/anemos.conf | 9 ++++ sqmeta/files/etc/hostname | 1 + sqmeta/files/etc/network/interfaces | 5 +++ 6 files changed, 112 insertions(+) create mode 100644 justfile create mode 100644 sqmeta/ADDRESS create mode 100644 sqmeta/IMGBUILD create mode 100644 sqmeta/files/etc/anemos.conf create mode 100644 sqmeta/files/etc/hostname create mode 100644 sqmeta/files/etc/network/interfaces diff --git a/justfile b/justfile new file mode 100644 index 0000000..5acd4cb --- /dev/null +++ b/justfile @@ -0,0 +1,30 @@ +_default: + just --list + +# Check if host directory exists +host-dir-exists host: + #!/usr/bin/env sh + if [ ! -d {{host}} ]; then + echo "{{host}} does not exist" + exit 1 + fi + +# Check host reachability via ping +host-reachable host: (host-dir-exists host) + #!/usr/bin/env sh + ping -w 1 -c 1 $(cat ./{{host}}/ADDRESS) + if [ $? -ne 0 ]; then + echo "{{host}} is not reachable" + exit 1 + fi + +# Test the IMGBUILD by building an image +test host: (host-dir-exists host) + #!/usr/bin/env sh + cd ./{{host}} + sudo makeimg --format "raw 4g msdos ext4" + +get-anemos host: (host-reachable host) + #!/usr/bin/env/sh + address=$(cat ./{{host}}/ADDRESS) + ssh root@$address wget https://git.sr.ht/~bitfehler/anemos-cli/blob/master/anemos diff --git a/sqmeta/ADDRESS b/sqmeta/ADDRESS new file mode 100644 index 0000000..824338e --- /dev/null +++ b/sqmeta/ADDRESS @@ -0,0 +1 @@ +10.1.33.169 diff --git a/sqmeta/IMGBUILD b/sqmeta/IMGBUILD new file mode 100644 index 0000000..a343c53 --- /dev/null +++ b/sqmeta/IMGBUILD @@ -0,0 +1,66 @@ +imgname=sqmeta +target=alpine +format="custom" + +# Sections +# Core system +# Provisioning +# Anemos +# Other +packages=" + alpine-base + linux-virt + syslinux + e2fsprogs + + lsblk + + zstd + curl + + openssh +" + +services=" + networking:boot + sshd +" + +setup() { + # Repartition + parted -s -- /dev/vda mklabel msdos \ + mkpart primary 2048s 256MiB \ + mkpart primary 256MiB -1s \ + set 1 boot on + partprobe /dev/vda + + # wait for hotplug events to settle... + sleep 1 && mdev -sf + + uuidr=$(uuidgen) + uuidb=$(uuidgen) + mkfs.ext2 -q -F -U "$uuidb" /dev/vda1 + mkfs.ext4 -q -F -U "$uuidr" /dev/vda2 + mount /dev/vda2 "${imgroot}" + mkdir "${imgroot}/boot" + mount /dev/vda1 "${imgroot}/boot" + mkdir "${imgroot}/etc" + opts=$(findmnt -no OPTIONS /dev/vda2) + printf "UUID=%s\t/\t%s\t%s\t0 1\n" "${uuidr}" "ext4" "${opts}" > "${imgroot}/etc/fstab" + opts=$(findmnt -no OPTIONS /dev/vda1) + printf "UUID=%s\t/boot\t%s\t%s\t0 2\n" "${uuidb}" "ext2" "${opts},noauto" >> "${imgroot}/etc/fstab" +} + +cleanup() { + umount "${imgroot}/boot" + umount "${imgroot}" +} + +provision() { + # Bootloader + uuid=$(lsblk -rno UUID /dev/vda2) + sed -e "s|^root=|root=/dev/disk/by-uuid/${uuid}|" -i /etc/update-extlinux.conf + dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of="${BLKDEV}" + extlinux --install /boot + update-extlinux -v +} diff --git a/sqmeta/files/etc/anemos.conf b/sqmeta/files/etc/anemos.conf new file mode 100644 index 0000000..53b07eb --- /dev/null +++ b/sqmeta/files/etc/anemos.conf @@ -0,0 +1,9 @@ +ANEMOS_INITRAMFS_URL="https://anemos.io/initramfs/3.22/initramfs-anemos" +ANEMOS_KERNEL_URL="https://anemos.io/initramfs/3.22/vmlinuz-anemos" + +ANEMOS_PAYLOAD_URL="file:///root/payload.tar.gz" + +ANEMOS_EXEC="destructive" +ANEMOS_OVERWRITE_KERNEL="/boot/$(cat /proc/cmdline | tr ' ' '\n' | grep BOOT_IMAGE= | cut -c 12-)" +ANEMOS_OVERWRITE_INITRAMFS="$(echo "${ANEMOS_OVERWRITE_KERNEL}" | sed -e s/vmlinuz/initramfs/)" +ANEMOS_OVERWRITE_BACKUP_EXT="yes" diff --git a/sqmeta/files/etc/hostname b/sqmeta/files/etc/hostname new file mode 100644 index 0000000..e46c45a --- /dev/null +++ b/sqmeta/files/etc/hostname @@ -0,0 +1 @@ +sqmeta diff --git a/sqmeta/files/etc/network/interfaces b/sqmeta/files/etc/network/interfaces new file mode 100644 index 0000000..104c1a1 --- /dev/null +++ b/sqmeta/files/etc/network/interfaces @@ -0,0 +1,5 @@ +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp -- 2.44.1