This commit is contained in:
Tiara Rodney 2026-03-14 05:38:45 +01:00
commit 883f31932e
No known key found for this signature in database
GPG key ID: 5CD8EC1D46106723
169 changed files with 5676 additions and 0 deletions

48
scripts/vm/create.sh Executable file
View file

@ -0,0 +1,48 @@
#!/bin/sh
# First-time setup: download image, create volumes, provision VMs,
# wait for cloud-init, then snapshot as "initialized".
set -eu
. "$(dirname "$0")/env.sh"
echo "==> Downloading cloud image"
"$QEMU_VM" image download
echo "==> Creating volumes"
"$QEMU_VM" volume create "$PROXY_VM" --size 20G --backing debian-12
"$QEMU_VM" volume create "$IDP_VM" --size 20G --backing debian-12
echo "==> Preparing TAP interfaces"
sudo --preserve-env=QEMU_VM "$(dirname "$0")/setup-taps.sh"
echo "==> Clearing stale SSH host keys"
clear_host_keys
echo "==> Creating instances (in screen sessions)"
screen -dmS "$PROXY_VM" \
"$QEMU_VM" instance create "$PROXY_VM" 0 \
--network "$NETWORK" --ip "$PROXY_IP" --headless
screen -dmS "$IDP_VM" \
"$QEMU_VM" instance create "$IDP_VM" 0 \
--network "$NETWORK" --ip "$IDP_IP" --headless
echo "==> Waiting for cloud-init"
wait_ssh "$PROXY_HOST"
# shellcheck disable=SC2086
ssh $SSH_OPTS "${SSH_USER}@${PROXY_HOST}" 'cloud-init status --wait'
echo " $PROXY_VM ready"
wait_ssh "$IDP_HOST"
# shellcheck disable=SC2086
ssh $SSH_OPTS "${SSH_USER}@${IDP_HOST}" 'cloud-init status --wait'
echo " $IDP_VM ready"
echo "==> Stopping for initial snapshot"
"$QEMU_VM" instance stop "$PROXY_VM"
"$QEMU_VM" instance stop "$IDP_VM"
echo "==> Snapshotting 'initialized'"
"$QEMU_VM" volume snapshot "$PROXY_VM" initialized
"$QEMU_VM" volume snapshot "$IDP_VM" initialized
echo "==> Done. Run: scripts/vm/start.sh"