Add runtime options and schema

This commit is contained in:
Thales Maciel 2026-01-29 00:59:48 -03:00
parent e4039ca7e9
commit eedc1fe1d8
No known key found for this signature in database
GPG key ID: 33112E6833C34679
4 changed files with 2034 additions and 24 deletions

View file

@ -6,27 +6,35 @@ log() {
}
cleanup() {
if [[ -n "${VM_INFO:-}" && -f "$VM_INFO" ]]; then
# shellcheck disable=SC1090
source "$VM_INFO"
if [[ -n "${pid:-}" ]]; then
sudo kill "$pid" 2>/dev/null || true
fi
if [[ -n "${tap:-}" ]]; then
sudo ip link del "$tap" 2>/dev/null || true
fi
if [[ -n "${vm_dir:-}" ]]; then
rm -rf "$vm_dir"
fi
if [[ -z "${VM_INFO:-}" || ! -f "$VM_INFO" ]]; then
return
fi
# shellcheck disable=SC1090
source "$VM_INFO"
if [[ -n "${pid:-}" ]]; then
sudo kill "$pid" 2>/dev/null || true
fi
if [[ -n "${tap:-}" ]]; then
sudo ip link del "$tap" 2>/dev/null || true
fi
if [[ -n "${vm_dir:-}" ]]; then
rm -rf "$vm_dir"
fi
}
trap cleanup EXIT
log "starting VM"
./run.sh
if ! ./run.sh; then
log "run.sh failed"
exit 1
fi
VM_DIR="$(ls -dt state/vm-* | head -n 1)"
VM_DIR="$(find state -maxdepth 1 -type d -name 'vm-*' -printf '%T@ %p\n' 2>/dev/null | sort -nr | head -n 1 | awk '{print $2}')"
if [[ -z "$VM_DIR" ]]; then
log "no VM state directory found"
exit 1
fi
VM_INFO="$VM_DIR/info"
if [[ ! -f "$VM_INFO" ]]; then
log "info file not found: $VM_INFO"
@ -37,6 +45,11 @@ fi
source "$VM_INFO"
vm_dir="$VM_DIR"
if [[ -z "${name:-}" || -z "${created_at:-}" || -z "${guest_ip:-}" ]]; then
log "missing name or created_at in info file"
exit 1
fi
log "asserting VM is reachable via SSH"
ssh -i "./id_ed25519" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
"root@${guest_ip}" "uname -a" >/dev/null