Add repo guidelines and verify script
This commit is contained in:
parent
dba2f327f5
commit
5b1de19cf5
3 changed files with 129 additions and 9 deletions
57
verify.sh
Executable file
57
verify.sh
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
log() {
|
||||
printf '[verify] %s\n' "$*"
|
||||
}
|
||||
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
log "starting VM"
|
||||
./run.sh
|
||||
|
||||
VM_DIR="$(ls -dt state/vm-* | head -n 1)"
|
||||
VM_INFO="$VM_DIR/info"
|
||||
if [[ ! -f "$VM_INFO" ]]; then
|
||||
log "info file not found: $VM_INFO"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$VM_INFO"
|
||||
vm_dir="$VM_DIR"
|
||||
|
||||
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
|
||||
|
||||
log "cleaning up VM"
|
||||
cleanup
|
||||
|
||||
log "asserting cleanup success"
|
||||
if ip link show "$tap" >/dev/null 2>&1; then
|
||||
log "tap still exists: $tap"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -d "$vm_dir" ]]; then
|
||||
log "vm dir still exists: $vm_dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "ok"
|
||||
Loading…
Add table
Add a link
Reference in a new issue