session1/ now holds the whole live lab (content, platforms, docs, answer key, README); session2/ keeps the design for the second workshop. The root README indexes both and states that session2 modifies session1 rather than duplicating it. build-bundle.sh builds from session1 and still produces a flat archive, so the documented paths inside a deployment (platforms/<p>/lab.sh) are unchanged. .gitignore follows the move.
81 lines
1.8 KiB
Bash
81 lines
1.8 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"
|
|
}
|
|
|
|
|
|
# The closing step of every change: freeze the current state into the
|
|
# baseline, then bring the lab back up. Falls back to a first-time snapshot
|
|
# when no baseline exists yet.
|
|
cmd_save() {
|
|
local name need_full=0
|
|
|
|
if declare -F backend_has_baseline >/dev/null; then
|
|
for name in "${VM_NAMES[@]}"; do
|
|
backend_has_baseline "$name" || need_full=1
|
|
done
|
|
else
|
|
need_full=1
|
|
fi
|
|
|
|
if (( need_full )); then
|
|
cmd_snapshot
|
|
else
|
|
cmd_snapshot --update
|
|
fi
|
|
|
|
step "start"
|
|
_start_lab
|
|
}
|