48 lines
1.4 KiB
Bash
Executable file
48 lines
1.4 KiB
Bash
Executable file
#!/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"
|