M .gitignore => .gitignore +3 -0
@@ 7,5 7,8 @@
/anemos-test.img
/anemos-test.packages
+# anemos payload
+/payload.tar.gz
+
# Alpine Linux keys
/files/etc/apk/keys/*
M .makeimg.modes => .makeimg.modes +4 -0
@@ 1,3 1,4 @@
+644 files/etc/anemos.conf
644 files/etc/apk/keys/alpine-devel@lists.alpinelinux.org-4a6a0840.rsa.pub
644 files/etc/apk/keys/alpine-devel@lists.alpinelinux.org-5243ef4b.rsa.pub
644 files/etc/apk/keys/alpine-devel@lists.alpinelinux.org-524d27bb.rsa.pub
@@ 17,3 18,6 @@
644 files/etc/apk/keys/alpine-devel@lists.alpinelinux.org-616db30d.rsa.pub
644 files/etc/apk/keys/alpine-devel@lists.alpinelinux.org-66ba20fe.rsa.pub
644 files/etc/apk/repositories
+644 files/etc/hostname
+644 files/etc/network/interfaces
+644 files/root/.ssh/authorized_keys
M IMGBUILD => IMGBUILD +62 -1
@@ 1,7 1,68 @@
imgname=anemos-test
target=alpine
-format="raw 4g msdos ext4"
+#format="raw 4g msdos ext4"
+format="custom"
+# Sections
+# Core system
+# Provisioning reqs
+# Anemos reqs
+# Other
packages="
alpine-base
+ linux-virt
+ syslinux
+ e2fsprogs
+
+ lsblk
+
+ zstd
+ curl
+
+ openssh
+"
+
+services="
+ networking:boot
+ sshd
"
+
+# FIXME: this was copied from ne nameserver example
+# maybe change to fdisk?
+setup() {
+ # Repartition, in case the disk das been reset to a vendor image
+ 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"
+ # Keep b
+ 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
+}
A README.md => README.md +28 -0
@@ 0,0 1,28 @@
+# anemos test
+
+## Installation on Proxmox VM
+1. Create VM with Alpine ISO (Standard)
+ 1. login as root
+ 2. setup-alpine
+ 1. default till root pwd
+ 1. set to something
+ 2. defaults till root ssh key
+ 1. https://meta.sr.ht/~liljamo.keys
+ 3. disk setup
+ 1. vda
+ 2. sys
+ 3. y
+ 3. reboot
+ 4. login as root
+ 5. deps
+ 1. enable community repo
+ 2. apk update
+ 3. apk add zstd curl
+2. just init
+3. add some program to makeimg
+4. just deploy
+5. see the new program installed, yay
+
+## Docs for stuff
+### anemos_init.conf
+https://git.sr.ht/~bitfehler/anemos-cli/tree/master/item/anemos.conf
A files/etc/anemos.conf => files/etc/anemos.conf +9 -0
@@ 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="/boot/$(echo "${ANEMOS_OVERWRITE_KERNEL}" | sed -e s/vmlinuz/initramfs/)"
+ANEMOS_OVERWRITE_BACKUP_EXT="yes"
A files/etc/hostname => files/etc/hostname +1 -0
@@ 0,0 1,1 @@
+anemostest
A files/etc/network/interfaces => files/etc/network/interfaces +5 -0
@@ 0,0 1,5 @@
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet dhcp
A files/root/.ssh/authorized_keys => files/root/.ssh/authorized_keys +1 -0
@@ 0,0 1,1 @@
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGAlif3ABIk0YSx++A+sEeRYPNMMZWLcDuoTKhmcCL6K jonni@liljamo.com
M justfile => justfile +39 -1
@@ 1,6 1,11 @@
+payload := "payload.tar.gz"
+host := "10.1.31.245"
+ssh_opts := "-i ~/.ssh/id_ed25519_jl"
+
_default:
just --list
+# Download alpine linux keys
alpine-keys:
#!/usr/bin/env sh
mkdir -p files/etc/apk/keys
@@ 33,5 38,38 @@ alpine-keys:
curl -O "https://git.alpinelinux.org/aports/plain/main/alpine-keys/${key}"
done
-build:
+# Test the IMGBUILD
+test:
sudo makeimg
+ rm ./anemos-test.img
+ rm ./anemos-test.packages
+
+# Check host reachability via ping
+check-host:
+ #!/usr/bin/env sh
+ ping -w 1 -c 1 {{host}}
+ if [ $? -ne 0 ]; then
+ echo "Host is not reachable"
+ exit 1
+ fi
+
+# Tar the anemos payload
+payload:
+ tar czf {{payload}} IMGBUILD files
+
+# Initialize with anemos on a new host
+init: check-host payload
+ scp {{ssh_opts}} {{payload}} files/etc/anemos.conf root@{{host}}:
+ ssh {{ssh_opts}} root@{{host}} wget https://git.sr.ht/~bitfehler/anemos-cli/blob/master/anemos
+ ssh {{ssh_opts}} root@{{host}} chmod +x anemos
+ ssh {{ssh_opts}} root@{{host}} ./anemos -c anemos.conf
+ rm {{payload}}
+
+# Deploy with anemos on an existing host
+deploy: check-host payload
+ scp {{ssh_opts}} {{payload}} root@{{host}}:
+ ssh {{ssh_opts}} root@{{host}} wget https://git.sr.ht/~bitfehler/anemos-cli/blob/master/anemos
+ ssh {{ssh_opts}} root@{{host}} chmod +x anemos
+ ssh {{ssh_opts}} root@{{host}} mount /boot
+ ssh {{ssh_opts}} root@{{host}} ./anemos
+ rm {{payload}}