Files
pentest.intro/content/lib/cmd_snapshot.sh
T
quoije 890dd58700 Split into qemu and proxmox platforms over a shared content tree
platforms/qemu and platforms/proxmox each have their own lab.sh and
lab.conf; content/ holds everything shared (roles, seed, site, helpers).
The dispatcher, preflight and command implementations are common and take
platform differences from the backend.

Proxmox backend: qm create with q35/SATA/e1000, ISOs and seed ISOs in an
ISO storage, provisioning over qm guest exec (no Python packages needed on
the host), template + clone for reset, and peers/ to emit WireGuard configs.
The role scripts now ride on the seed ISO, so provisioning transfers nothing.

build-bundle.sh produces a self-contained tarball per platform, for hosts
that cannot reach the git server.

Both configs are generic: no absolute path from this machine remains.
2026-10-22 19:23:16 -04:00

56 lines
1.3 KiB
Bash

# shellcheck shell=bash
# cmd_snapshot / cmd_reset — freeze a clean baseline and revert to it.
# qemu backend: the golden disk becomes a read-only base, each run boots a
# thin overlay. Reset deletes the overlay, so it takes about a second.
cmd_snapshot() {
local name update=0
for name in "$@"; do
case $name in
--update) update=1 ;;
-h|--help) info "usage: ./lab.sh snapshot [--update]"; return 0 ;;
*) die "unknown argument: $name" ;;
esac
done
step "stop"
for name in "${VM_NAMES[@]}"; do
backend_stop "$name"
done
if (( update )); then
step "commit current state into the baseline"
for name in "${VM_NAMES[@]}"; do
backend_commit "$name" || die "commit failed for $name"
done
printf '\n'
ok "baseline updated"
info " ./lab.sh up to start · ./lab.sh reset to revert to this state"
return 0
fi
step "freeze baseline"
for name in "${VM_NAMES[@]}"; do
backend_snapshot "$name" || die "snapshot failed for $name"
done
printf '\n'
ok "baseline ready"
info " start with ./lab.sh up · revert with ./lab.sh reset"
}
cmd_reset() {
local name
step "revert to baseline"
for name in "${VM_NAMES[@]}"; do
backend_reset "$name" || die "reset failed for $name"
done
step "start"
_start_lab
printf '\n'
ok "laboratory reset — previous state discarded"
}