prepare_site.py rebuilds web/site/ from site-src/: rebuilt home page, repaired images, Wayback links resolved to local files or neutralised, hit counter removed, crawler metadata dropped, home page breadcrumb. Link check fails the build on dangling references. Seed layer adds public/IT-inventaire.txt and robots.txt.
138 lines
3.6 KiB
Bash
Executable File
138 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# lab.sh — entry point for the Norbourg pentest lab.
|
|
# Backend-agnostic commands live in lib/, backend specifics in backends/.
|
|
set -euo pipefail
|
|
|
|
LAB_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)
|
|
export LAB_DIR
|
|
|
|
# shellcheck source=lib/common.sh
|
|
source "$LAB_DIR/lib/common.sh"
|
|
# shellcheck source=lib/check.sh
|
|
source "$LAB_DIR/lib/check.sh"
|
|
# shellcheck source=lib/cmd_init.sh
|
|
source "$LAB_DIR/lib/cmd_init.sh"
|
|
# shellcheck source=lib/cmd_web.sh
|
|
source "$LAB_DIR/lib/cmd_web.sh"
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Norbourg lab ${LAB_SH_VERSION}
|
|
|
|
Usage: ./lab.sh [options] <command>
|
|
|
|
Options:
|
|
--backend qemu|proxmox override lab.conf
|
|
--strict treat check warnings as failures
|
|
-v, --verbose extra detail
|
|
-h, --help this text
|
|
|
|
Commands:
|
|
check preflight: host, KVM, storage, network, config
|
|
init create the storage layout
|
|
build create VMs, run unattended installs (phase 3)
|
|
provision run role scripts over WinRM (phase 5)
|
|
snapshot freeze a clean baseline (phase 8)
|
|
up, down start / stop the VMs (phase 3)
|
|
reset revert to baseline (phase 8)
|
|
status VM table (phase 8)
|
|
web sync the archived site to FS01 (phase 7)
|
|
doctor participant connectivity checklist (phase 8)
|
|
peers WireGuard peer configs (proxmox only) (phase 11)
|
|
export-kali build the participant Kali image (phase 9)
|
|
answers instructor walkthrough (phase 9)
|
|
destroy remove VMs and generated artifacts (phase 8)
|
|
EOF
|
|
}
|
|
|
|
planned() {
|
|
warn "'$1' is not implemented yet — planned for $2"
|
|
return 3
|
|
}
|
|
|
|
# ------------------------------------------------------------------ arguments
|
|
BACKEND_OVERRIDE=""
|
|
cmd=""
|
|
|
|
while (( $# > 0 )); do
|
|
case $1 in
|
|
--backend)
|
|
[[ $# -ge 2 ]] || die "--backend needs a value (qemu|proxmox)"
|
|
BACKEND_OVERRIDE=$2
|
|
shift 2
|
|
;;
|
|
--backend=*)
|
|
BACKEND_OVERRIDE=${1#*=}
|
|
shift
|
|
;;
|
|
--strict)
|
|
STRICT=1
|
|
shift
|
|
;;
|
|
-v|--verbose)
|
|
VERBOSE=1
|
|
shift
|
|
;;
|
|
-h|--help|help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
--version)
|
|
printf '%s\n' "$LAB_SH_VERSION"
|
|
exit 0
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
-*)
|
|
die "unknown option: $1 (try --help)"
|
|
;;
|
|
*)
|
|
if [[ -z $cmd ]]; then
|
|
cmd=$1
|
|
shift
|
|
else
|
|
die "unexpected argument: $1 (try --help)"
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z $cmd ]]; then
|
|
usage
|
|
exit 2
|
|
fi
|
|
|
|
load_config
|
|
[[ -n $BACKEND_OVERRIDE ]] && BACKEND=$BACKEND_OVERRIDE
|
|
|
|
case $BACKEND in
|
|
qemu|proxmox)
|
|
# shellcheck source=backends/qemu.sh
|
|
source "$LAB_DIR/backends/${BACKEND}.sh"
|
|
;;
|
|
*)
|
|
die "unknown backend: ${BACKEND} (expected qemu or proxmox)"
|
|
;;
|
|
esac
|
|
|
|
# ------------------------------------------------------------------ dispatch
|
|
case $cmd in
|
|
check) cmd_check || exit $? ;;
|
|
init) cmd_init ;;
|
|
build) planned build "phase 3" ;;
|
|
provision) planned provision "phase 5" ;;
|
|
snapshot) planned snapshot "phase 8" ;;
|
|
up|down) planned "$cmd" "phase 3" ;;
|
|
reset) planned reset "phase 8" ;;
|
|
status) planned status "phase 8" ;;
|
|
web) cmd_web ;;
|
|
doctor) planned doctor "phase 8" ;;
|
|
peers) planned peers "phase 11" ;;
|
|
export-kali) planned export-kali "phase 9" ;;
|
|
answers) planned answers "phase 9" ;;
|
|
destroy) planned destroy "phase 8" ;;
|
|
*) die "unknown command: ${cmd} (try --help)" ;;
|
|
esac
|