Phase 3: unattended install, seed ISOs and VM lifecycle
autounattend template (q35/AHCI/e1000, no virtio injection), per-VM seed ISOs with a bootstrap that configures the static IP, enables WinRM/RDP and chains into the role script. build --dry-run, up/down/status/vnc verbs. Static addressing happens in PowerShell rather than in the unattend file: Microsoft-Windows-TCPIP matches adapters by connection name and fails silently when the name differs.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Laboratoire Norbourg — atelier d'introduction au pentest de domaine
|
# Laboratoire Norbourg — atelier d'introduction au pentest de domaine
|
||||||
|
|
||||||
> **État : phase 1 (échafaudage).** Aucune machine virtuelle n'est encore déployée.
|
> **État : phase 3.** L'échafaudage, la préparation du site et l'installation automatique sont
|
||||||
> Les commandes marquées « à venir » existent dans l'interface mais ne font rien pour l'instant.
|
> prêts. Le réseau isolé demande encore une commande `sudo`, et le domaine n'est pas monté.
|
||||||
|
|
||||||
Laboratoire Active Directory isolé, déployé par script, pour initier des collègues au pentest de
|
Laboratoire Active Directory isolé, déployé par script, pour initier des collègues au pentest de
|
||||||
domaine. L'objectif de l'atelier : partir d'un accès anonyme et obtenir les droits de
|
domaine. L'objectif de l'atelier : partir d'un accès anonyme et obtenir les droits de
|
||||||
@@ -43,19 +43,26 @@ br-lab 10.10.10.230
|
|||||||
./lab.sh check # vérifie l'hôte, le stockage, le réseau et la configuration
|
./lab.sh check # vérifie l'hôte, le stockage, le réseau et la configuration
|
||||||
./lab.sh check -v # avec le détail
|
./lab.sh check -v # avec le détail
|
||||||
./lab.sh init # crée l'arborescence de stockage
|
./lab.sh init # crée l'arborescence de stockage
|
||||||
|
./lab.sh isos # télécharge les images Windows dans le cache ISO
|
||||||
|
./lab.sh seeds # génère les fichiers de réponse et les ISO d'amorçage
|
||||||
```
|
```
|
||||||
|
|
||||||
`check` refuse de continuer si le stockage est inadapté (NTFS, système de fichiers en erreur,
|
`check` refuse de continuer si le stockage est inadapté (NTFS, système de fichiers en erreur,
|
||||||
espace insuffisant). Les avertissements réseau sont normaux tant que la phase 2 n'est pas faite.
|
espace insuffisant). Les avertissements réseau sont normaux tant que le pont n'existe pas.
|
||||||
|
|
||||||
Prochaines étapes, dans l'ordre :
|
Ensuite, une seule commande demande `sudo` :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo ./scripts/setup-network.sh # à venir — pont br-lab et isolation
|
sudo ./scripts/setup-network.sh # pont br-lab, isolation, redirection IP
|
||||||
./lab.sh build # à venir — installation des VM
|
./lab.sh build # disques + installation des 3 VM, sans intervention
|
||||||
./lab.sh provision # à venir — domaine, comptes, ACL
|
./lab.sh status
|
||||||
|
./lab.sh vnc dc01 # console graphique pendant l'installation
|
||||||
|
./lab.sh provision # à venir (phase 5) : domaine, comptes, ACL
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`build` attend que chaque VM réponde sur WinRM (port 5985) et signale celles qui tardent.
|
||||||
|
`./lab.sh build --dry-run` affiche les commandes QEMU sans rien créer.
|
||||||
|
|
||||||
## Structure du dépôt
|
## Structure du dépôt
|
||||||
|
|
||||||
| Chemin | Rôle |
|
| Chemin | Rôle |
|
||||||
@@ -67,7 +74,7 @@ sudo ./scripts/setup-network.sh # à venir — pont br-lab et isolation
|
|||||||
| `seed/` | fichiers de réponse Windows et fabrication des ISO d'amorçage |
|
| `seed/` | fichiers de réponse Windows et fabrication des ISO d'amorçage |
|
||||||
| `windows/roles/` | scripts PowerShell par machine (à venir) |
|
| `windows/roles/` | scripts PowerShell par machine (à venir) |
|
||||||
| `site-src/` | site Norbourg 2002 : miroir, images retouchées, scripts d'origine |
|
| `site-src/` | site Norbourg 2002 : miroir, images retouchées, scripts d'origine |
|
||||||
| `web/` | site assemblé pour FS01 et fichiers pièges (à venir) |
|
| `web/` | site assemblé pour FS01, fichiers pièges |
|
||||||
| `docs/` | documentation de l'atelier (à venir) |
|
| `docs/` | documentation de l'atelier (à venir) |
|
||||||
| `answers/` | solution complète — **ignoré par git** |
|
| `answers/` | solution complète — **ignoré par git** |
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# QEMU/KVM backend — local development and dry runs.
|
# QEMU/KVM backend — local development and dry runs.
|
||||||
|
#
|
||||||
|
# Hardware model matches the Proxmox target on purpose: q35 + AHCI (SATA) and
|
||||||
|
# an e1000 NIC, so the unattended file never needs virtio drivers.
|
||||||
|
|
||||||
backend_check() {
|
backend_check() {
|
||||||
if qemu-system-x86_64 -M help 2>/dev/null | grep -q '^q35'; then
|
if qemu-system-x86_64 -M help 2>/dev/null | grep -q '^q35'; then
|
||||||
@@ -35,3 +38,141 @@ backend_check() {
|
|||||||
_c_warn "qemu-bridge-helper not found: unprivileged bridge attach will fail"
|
_c_warn "qemu-bridge-helper not found: unprivileged bridge attach will fail"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ layout
|
||||||
|
qemu_disk() { printf '%s/images/%s.qcow2' "$LAB_ROOT" "$1"; }
|
||||||
|
qemu_pidfile(){ printf '%s/run/%s.pid' "$LAB_ROOT" "$1"; }
|
||||||
|
qemu_log() { printf '%s/run/%s.log' "$LAB_ROOT" "$1"; }
|
||||||
|
qemu_monitor(){ printf '%s/run/%s.monitor' "$LAB_ROOT" "$1"; }
|
||||||
|
|
||||||
|
# Deterministic MAC from the last two octets: 10.10.10.31 -> 52:54:00:0a:1f
|
||||||
|
qemu_mac_for() {
|
||||||
|
local ip=$1
|
||||||
|
local b3=${ip##*.}
|
||||||
|
local rest=${ip%.*}
|
||||||
|
local b2=${rest##*.}
|
||||||
|
printf '52:54:00:%02x:%02x' "$b2" "$b3"
|
||||||
|
}
|
||||||
|
|
||||||
|
backend_running() {
|
||||||
|
local pidfile pid
|
||||||
|
pidfile=$(qemu_pidfile "$1")
|
||||||
|
[[ -r $pidfile ]] || return 1
|
||||||
|
pid=$(<"$pidfile")
|
||||||
|
[[ -n $pid ]] && kill -0 "$pid" 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
backend_create_disk() {
|
||||||
|
local name=$1 dry=${2:-0}
|
||||||
|
local disk i size
|
||||||
|
disk=$(qemu_disk "$name")
|
||||||
|
i=$(vm_index "$name") || die "unknown vm: $name"
|
||||||
|
size=${VM_DISK[$i]}
|
||||||
|
|
||||||
|
if [[ -f $disk ]]; then
|
||||||
|
ok "$(printf '%-6s disk present (%s)' "$name" "$(du -h "$disk" | cut -f1)")"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
mkdir -p "$LAB_ROOT/images"
|
||||||
|
if (( dry )); then
|
||||||
|
info " + qemu-img create -f qcow2 $disk ${size}G"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
qemu-img create -q -f qcow2 "$disk" "${size}G"
|
||||||
|
ok "$(printf '%-6s disk created (%sG)' "$name" "$size")"
|
||||||
|
}
|
||||||
|
|
||||||
|
backend_launch() {
|
||||||
|
local name=$1 mode=${2:-run} dry=${3:-0}
|
||||||
|
local i ip ram vcpu disk seed win vnc
|
||||||
|
local boot_iso="" args=() cd=1
|
||||||
|
|
||||||
|
i=$(vm_index "$name") || die "unknown vm: $name"
|
||||||
|
ip=${VM_IPS[$i]}; ram=${VM_RAM[$i]}; vcpu=${VM_VCPU[$i]}
|
||||||
|
disk=$(qemu_disk "$name")
|
||||||
|
seed="$LAB_ROOT/seeds/$name-seed.iso"
|
||||||
|
win=$WINDOWS_ISO
|
||||||
|
vnc=$(( i + 1 ))
|
||||||
|
|
||||||
|
[[ -f $seed ]] || (( dry )) || die "missing seed ISO for $name (run ./lab.sh seeds)"
|
||||||
|
[[ -f $disk ]] || (( dry )) || die "missing disk for $name (run ./lab.sh build)"
|
||||||
|
|
||||||
|
if [[ $mode == install ]] && ! (( dry )); then
|
||||||
|
[[ -f $win ]] || die "missing Windows ISO: $win (run ./lab.sh isos)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
args=(
|
||||||
|
-name "norbourg-$name"
|
||||||
|
-machine q35,accel=kvm
|
||||||
|
-cpu host
|
||||||
|
-smp "${vcpu},sockets=1,cores=${vcpu}"
|
||||||
|
-m "$ram"
|
||||||
|
-rtc base=localtime,clock=host
|
||||||
|
-drive "if=none,id=disk,file=$disk,format=qcow2,cache=none,aio=native,discard=unmap"
|
||||||
|
-device ide-hd,drive=disk,bus=ide.0
|
||||||
|
-netdev "bridge,id=net0,br=$BRIDGE"
|
||||||
|
-device "e1000,netdev=net0,mac=$(qemu_mac_for "$ip")"
|
||||||
|
-monitor "unix:$(qemu_monitor "$name"),server,nowait"
|
||||||
|
-display none
|
||||||
|
-vnc "127.0.0.1:${vnc}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ $mode == install ]]; then
|
||||||
|
(( dry )) || [[ -f $win ]] || die "missing Windows ISO: $win (run ./lab.sh isos)"
|
||||||
|
args+=( -drive "if=none,id=cd-install,media=cdrom,file=$win"
|
||||||
|
-device "ide-cd,drive=cd-install,bus=ide.${cd}" )
|
||||||
|
cd=$(( cd + 1 ))
|
||||||
|
fi
|
||||||
|
args+=( -drive "if=none,id=cd-seed,media=cdrom,file=$seed"
|
||||||
|
-device "ide-cd,drive=cd-seed,bus=ide.${cd}" )
|
||||||
|
|
||||||
|
if [[ $mode == install ]]; then
|
||||||
|
# once=d: boot the install media this time only, then always from disk.
|
||||||
|
# Without `once`, Setup would re-enter itself after its own reboot.
|
||||||
|
args+=( -boot order=c,once=d )
|
||||||
|
else
|
||||||
|
args+=( -boot order=c )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( dry )); then
|
||||||
|
info " + qemu-system-x86_64 ${args[*]}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$LAB_ROOT/run"
|
||||||
|
nohup qemu-system-x86_64 "${args[@]}" >>"$(qemu_log "$name")" 2>&1 &
|
||||||
|
printf '%s\n' "$!" >"$(qemu_pidfile "$name")"
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if backend_running "$name"; then
|
||||||
|
ok "$(printf '%-6s started · vnc 127.0.0.1:%d · pid %s' "$name" "$(( 5900 + vnc ))" "$(<"$(qemu_pidfile "$name")")")"
|
||||||
|
else
|
||||||
|
fail "$name failed to start — see $(qemu_log "$name")"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
backend_stop() {
|
||||||
|
local name=$1 sock pid i
|
||||||
|
backend_running "$name" || { info " $name already stopped"; return 0; }
|
||||||
|
|
||||||
|
sock=$(qemu_monitor "$name")
|
||||||
|
pid=$(<"$(qemu_pidfile "$name")")
|
||||||
|
|
||||||
|
if [[ -S $sock ]]; then
|
||||||
|
printf 'system_powerdown\n' | socat - "UNIX-CONNECT:$sock" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
kill -0 "$pid" 2>/dev/null || break
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
if kill -0 "$pid" 2>/dev/null; then
|
||||||
|
warn "$name did not shut down cleanly, sending TERM"
|
||||||
|
kill "$pid" 2>/dev/null || true
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
rm -f "$(qemu_pidfile "$name")"
|
||||||
|
ok "$name stopped"
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ LAB_ROOT="/home/quoije/lab-vms/pentest-lab"
|
|||||||
LAB_ISO_CACHE="/media/amy/pentest-lab-iso"
|
LAB_ISO_CACHE="/media/amy/pentest-lab-iso"
|
||||||
MIN_FREE_GB=20
|
MIN_FREE_GB=20
|
||||||
|
|
||||||
|
# Resolved by `lab.sh isos`.
|
||||||
|
WINDOWS_ISO="$LAB_ISO_CACHE/SERVER_EVAL_x64FRE_en-us.iso"
|
||||||
|
VIRTIO_ISO="$LAB_ISO_CACHE/virtio-win.iso"
|
||||||
|
|
||||||
# ---------------------------------------------------------------- vms
|
# ---------------------------------------------------------------- vms
|
||||||
# name ip ram_mb disk_gb vcpu role
|
# name ip ram_mb disk_gb vcpu role
|
||||||
VMS=$(cat <<'EOF'
|
VMS=$(cat <<'EOF'
|
||||||
@@ -44,6 +48,11 @@ EOF
|
|||||||
)
|
)
|
||||||
|
|
||||||
# ---------------------------------------------------------------- windows
|
# ---------------------------------------------------------------- windows
|
||||||
|
# Local administrator password used by the unattend file. Override it in
|
||||||
|
# lab.conf.local for anything that is not a throwaway lab.
|
||||||
|
LAB_ADMIN_PASSWORD="${LAB_ADMIN_PASSWORD:-Norbourg!2026}"
|
||||||
|
# Index of the image inside the eval ISO (2 = Standard, Desktop Experience).
|
||||||
|
WINDOWS_IMAGE_INDEX=2
|
||||||
# Local milestone uses Server 2022 for every role (no TPM/Secure Boot friction).
|
# Local milestone uses Server 2022 for every role (no TPM/Secure Boot friction).
|
||||||
# Proxmox enables Windows 11 workstations and the WS02 decoy.
|
# Proxmox enables Windows 11 workstations and the WS02 decoy.
|
||||||
WORKSTATION_OS="srv2022" # srv2022 | win11
|
WORKSTATION_OS="srv2022" # srv2022 | win11
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ source "$LAB_DIR/lib/check.sh"
|
|||||||
source "$LAB_DIR/lib/cmd_init.sh"
|
source "$LAB_DIR/lib/cmd_init.sh"
|
||||||
# shellcheck source=lib/cmd_web.sh
|
# shellcheck source=lib/cmd_web.sh
|
||||||
source "$LAB_DIR/lib/cmd_web.sh"
|
source "$LAB_DIR/lib/cmd_web.sh"
|
||||||
|
# shellcheck source=lib/cmd_isos.sh
|
||||||
|
source "$LAB_DIR/lib/cmd_isos.sh"
|
||||||
|
# shellcheck source=lib/cmd_seeds.sh
|
||||||
|
source "$LAB_DIR/lib/cmd_seeds.sh"
|
||||||
|
# shellcheck source=lib/cmd_build.sh
|
||||||
|
source "$LAB_DIR/lib/cmd_build.sh"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@@ -30,12 +36,15 @@ Options:
|
|||||||
Commands:
|
Commands:
|
||||||
check preflight: host, KVM, storage, network, config
|
check preflight: host, KVM, storage, network, config
|
||||||
init create the storage layout
|
init create the storage layout
|
||||||
|
isos download the Windows media into LAB_ISO_CACHE
|
||||||
|
seeds render unattend files and pack the seed ISOs
|
||||||
build create VMs, run unattended installs (phase 3)
|
build create VMs, run unattended installs (phase 3)
|
||||||
provision run role scripts over WinRM (phase 5)
|
provision run role scripts over WinRM (phase 5)
|
||||||
snapshot freeze a clean baseline (phase 8)
|
snapshot freeze a clean baseline (phase 8)
|
||||||
up, down start / stop the VMs (phase 3)
|
up, down start / stop the VMs (phase 3)
|
||||||
reset revert to baseline (phase 8)
|
reset revert to baseline (phase 8)
|
||||||
status VM table (phase 8)
|
status VM table: state, pid, VNC display
|
||||||
|
vnc open a console on a VM
|
||||||
web sync the archived site to FS01 (phase 7)
|
web sync the archived site to FS01 (phase 7)
|
||||||
doctor participant connectivity checklist (phase 8)
|
doctor participant connectivity checklist (phase 8)
|
||||||
peers WireGuard peer configs (proxmox only) (phase 11)
|
peers WireGuard peer configs (proxmox only) (phase 11)
|
||||||
@@ -86,7 +95,11 @@ while (( $# > 0 )); do
|
|||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
|
# Before the command this is a typo; after it, the flag belongs to the verb.
|
||||||
|
if [[ -z $cmd ]]; then
|
||||||
die "unknown option: $1 (try --help)"
|
die "unknown option: $1 (try --help)"
|
||||||
|
fi
|
||||||
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ -z $cmd ]]; then
|
if [[ -z $cmd ]]; then
|
||||||
@@ -120,14 +133,18 @@ esac
|
|||||||
# ------------------------------------------------------------------ dispatch
|
# ------------------------------------------------------------------ dispatch
|
||||||
case $cmd in
|
case $cmd in
|
||||||
check) cmd_check || exit $? ;;
|
check) cmd_check || exit $? ;;
|
||||||
init) cmd_init ;;
|
init) cmd_init "$@" ;;
|
||||||
build) planned build "phase 3" ;;
|
isos) cmd_isos "$@" ;;
|
||||||
|
seeds) cmd_seeds "$@" ;;
|
||||||
|
web) cmd_web "$@" ;;
|
||||||
|
build) cmd_build "$@" ;;
|
||||||
|
up) cmd_up "$@" ;;
|
||||||
|
down) cmd_down "$@" ;;
|
||||||
|
status) cmd_status "$@" ;;
|
||||||
|
vnc) cmd_vnc "$@" ;;
|
||||||
provision) planned provision "phase 5" ;;
|
provision) planned provision "phase 5" ;;
|
||||||
snapshot) planned snapshot "phase 8" ;;
|
snapshot) planned snapshot "phase 8" ;;
|
||||||
up|down) planned "$cmd" "phase 3" ;;
|
|
||||||
reset) planned reset "phase 8" ;;
|
reset) planned reset "phase 8" ;;
|
||||||
status) planned status "phase 8" ;;
|
|
||||||
web) cmd_web ;;
|
|
||||||
doctor) planned doctor "phase 8" ;;
|
doctor) planned doctor "phase 8" ;;
|
||||||
peers) planned peers "phase 11" ;;
|
peers) planned peers "phase 11" ;;
|
||||||
export-kali) planned export-kali "phase 9" ;;
|
export-kali) planned export-kali "phase 9" ;;
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
# cmd_build / cmd_up / cmd_down / cmd_status — VM lifecycle for the qemu backend.
|
||||||
|
|
||||||
|
cmd_build() {
|
||||||
|
local dry=0 arg
|
||||||
|
for arg in "$@"; do
|
||||||
|
case $arg in
|
||||||
|
--dry-run) dry=1 ;;
|
||||||
|
-h|--help) info "usage: ./lab.sh build [--dry-run]"; return 0 ;;
|
||||||
|
*) die "unknown argument: $arg" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
step "answer files"
|
||||||
|
if (( dry )); then
|
||||||
|
info " + render ${#VM_NAMES[@]} unattend file(s) and pack seed ISOs"
|
||||||
|
else
|
||||||
|
cmd_seeds >/dev/null || die "seed build failed"
|
||||||
|
ok "${#VM_NAMES[@]} seed ISO(s) ready"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f $WINDOWS_ISO ]]; then
|
||||||
|
(( dry )) || die "missing Windows ISO: $WINDOWS_ISO (run ./lab.sh isos)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
step "virtual disks"
|
||||||
|
local name
|
||||||
|
for name in "${VM_NAMES[@]}"; do
|
||||||
|
backend_create_disk "$name" "$dry"
|
||||||
|
done
|
||||||
|
|
||||||
|
step "launch"
|
||||||
|
for name in "${VM_NAMES[@]}"; do
|
||||||
|
if backend_running "$name"; then
|
||||||
|
info " $name already running"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
backend_launch "$name" install "$dry" || die "could not start $name"
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( dry )); then
|
||||||
|
printf '\n'
|
||||||
|
ok "dry run complete — nothing was created"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
_wait_for_boot
|
||||||
|
}
|
||||||
|
|
||||||
|
_wait_for_boot() {
|
||||||
|
local deadline=$(( SECONDS + ${BUILD_TIMEOUT:-2700} ))
|
||||||
|
local i name ip
|
||||||
|
local -A pending=()
|
||||||
|
|
||||||
|
for i in "${!VM_NAMES[@]}"; do
|
||||||
|
backend_running "${VM_NAMES[$i]}" && pending["${VM_NAMES[$i]}"]=${VM_IPS[$i]}
|
||||||
|
done
|
||||||
|
|
||||||
|
step "waiting for unattended installs"
|
||||||
|
info " poll every 15 s, up to $(( ${BUILD_TIMEOUT:-2700} / 60 )) min"
|
||||||
|
info " watch one: ./lab.sh vnc <vm> · logs: ${LAB_ROOT}/run/"
|
||||||
|
|
||||||
|
local reported=1
|
||||||
|
while (( ${#pending[@]} > 0 )); do
|
||||||
|
if (( SECONDS > deadline )); then
|
||||||
|
fail "timed out waiting for: ${!pending[*]}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
for name in "${!pending[@]}"; do
|
||||||
|
if tcp_open "${pending[$name]}" 5985; then
|
||||||
|
ok "$(printf '%-6s installed and reachable on 5985' "$name")"
|
||||||
|
unset 'pending[$name]'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if (( ${#pending[@]} > 0 )); then
|
||||||
|
if (( SECONDS - reported >= 60 )); then
|
||||||
|
info " still waiting: ${!pending[*]}"
|
||||||
|
reported=$SECONDS
|
||||||
|
fi
|
||||||
|
sleep 15
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
printf '\n'
|
||||||
|
ok "all VMs installed and reachable"
|
||||||
|
info " next: ./lab.sh status"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_up() {
|
||||||
|
local name
|
||||||
|
step "start"
|
||||||
|
for name in "${VM_NAMES[@]}"; do
|
||||||
|
if backend_running "$name"; then
|
||||||
|
info " $name already running"
|
||||||
|
else
|
||||||
|
backend_launch "$name" run || fail "$name did not start"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_down() {
|
||||||
|
local name
|
||||||
|
step "stop"
|
||||||
|
for name in "${VM_NAMES[@]}"; do
|
||||||
|
backend_stop "$name"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_status() {
|
||||||
|
local i name ip pid state sync
|
||||||
|
printf '\n%s%-7s %-14s %-9s %-8s %s%s\n' "$C_BOLD" VM IP STATE PID VNC "$C_RESET"
|
||||||
|
for i in "${!VM_NAMES[@]}"; do
|
||||||
|
name=${VM_NAMES[$i]}
|
||||||
|
ip=${VM_IPS[$i]}
|
||||||
|
if backend_running "$name"; then
|
||||||
|
state="running"
|
||||||
|
pid=$(<"$(qemu_pidfile "$name")")
|
||||||
|
else
|
||||||
|
state="stopped"
|
||||||
|
pid="-"
|
||||||
|
fi
|
||||||
|
printf '%-7s %-14s %-9s %-8s %s\n' "$name" "$ip" "$state" "$pid" "$(( 5900 + i + 1 ))"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Reachability is only meaningful once the guest has bootstrapped.
|
||||||
|
printf '\n'
|
||||||
|
for i in "${!VM_NAMES[@]}"; do
|
||||||
|
name=${VM_NAMES[$i]}
|
||||||
|
ip=${VM_IPS[$i]}
|
||||||
|
backend_running "$name" || continue
|
||||||
|
sync="no"
|
||||||
|
tcp_open "$ip" 5985 && sync="yes"
|
||||||
|
printf ' %-6s winrm: %s\n' "$name" "$sync"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_vnc() {
|
||||||
|
local name=${1:-}
|
||||||
|
local i
|
||||||
|
[[ -n $name ]] || die "usage: ./lab.sh vnc <vm> (VMs: ${VM_NAMES[*]})"
|
||||||
|
i=$(vm_index "$name") || die "unknown vm: $name"
|
||||||
|
local port=$(( 5900 + i + 1 ))
|
||||||
|
if have_cmd remote-viewer; then
|
||||||
|
exec remote-viewer "vnc://127.0.0.1:${port}"
|
||||||
|
elif have_cmd vncviewer; then
|
||||||
|
exec vncviewer "127.0.0.1:${port}"
|
||||||
|
fi
|
||||||
|
info "no VNC client found. Connect to 127.0.0.1:${port} (display :$(( i + 1 )))"
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
# cmd_isos — fetch the Windows media into LAB_ISO_CACHE.
|
||||||
|
# Read-only content, so an NTFS/FUSE cache directory is fine here.
|
||||||
|
|
||||||
|
# name|url|minimum size in MB
|
||||||
|
ISO_ITEMS=(
|
||||||
|
"SERVER_EVAL_x64FRE_en-us.iso|https://go.microsoft.com/fwlink/?linkid=2195280|2000"
|
||||||
|
"virtio-win.iso|https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso|200"
|
||||||
|
)
|
||||||
|
|
||||||
|
cmd_isos() {
|
||||||
|
have_cmd curl || die "curl is required"
|
||||||
|
mkdir -p "$LAB_ISO_CACHE" || die "cannot create $LAB_ISO_CACHE"
|
||||||
|
|
||||||
|
local item name url min_mb target tmp size_mb
|
||||||
|
for item in "${ISO_ITEMS[@]}"; do
|
||||||
|
IFS='|' read -r name url min_mb <<< "$item"
|
||||||
|
target="$LAB_ISO_CACHE/$name"
|
||||||
|
tmp="$target.part"
|
||||||
|
|
||||||
|
if [[ -f $target ]]; then
|
||||||
|
size_mb=$(( $(stat -c %s "$target") / 1024 / 1024 ))
|
||||||
|
if (( size_mb >= min_mb )); then
|
||||||
|
ok "$name present (${size_mb} MB)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
warn "$name is only ${size_mb} MB, re-downloading"
|
||||||
|
rm -f "$target"
|
||||||
|
fi
|
||||||
|
|
||||||
|
step "download $name"
|
||||||
|
info " from $url"
|
||||||
|
|
||||||
|
local curl_opts=(-L --fail --retry 3 --retry-delay 5 -C - -o "$tmp")
|
||||||
|
if [[ -t 1 ]]; then
|
||||||
|
curl "${curl_opts[@]}" --progress-bar "$url" || { rm -f "$tmp"; die "download failed: $name"; }
|
||||||
|
else
|
||||||
|
curl "${curl_opts[@]}" -sS "$url" || { rm -f "$tmp"; die "download failed: $name"; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv -f "$tmp" "$target"
|
||||||
|
size_mb=$(( $(stat -c %s "$target") / 1024 / 1024 ))
|
||||||
|
if (( size_mb < min_mb )); then
|
||||||
|
die "$name looks truncated: ${size_mb} MB (expected >= ${min_mb} MB)"
|
||||||
|
fi
|
||||||
|
ok "$name ready (${size_mb} MB)"
|
||||||
|
done
|
||||||
|
|
||||||
|
printf '\n'
|
||||||
|
ok "ISO cache complete: ${LAB_ISO_CACHE}"
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
# cmd_seeds — render one unattend + payload per VM and pack a seed ISO.
|
||||||
|
# Nothing here needs root or a downloaded ISO; it is pure file assembly.
|
||||||
|
|
||||||
|
cmd_seeds() {
|
||||||
|
local tmpl="$LAB_DIR/seed/Autounattend.xml.tmpl"
|
||||||
|
local payload="$LAB_DIR/seed/payload"
|
||||||
|
|
||||||
|
[[ -r $tmpl ]] || die "missing template: $tmpl"
|
||||||
|
[[ -d $payload ]] || die "missing payload dir: $payload"
|
||||||
|
have_cmd genisoimage || have_cmd xorriso || die "genisoimage or xorriso is required"
|
||||||
|
: "${LAB_ADMIN_PASSWORD:?LAB_ADMIN_PASSWORD is not set in lab.conf}"
|
||||||
|
|
||||||
|
mkdir -p "$LAB_ROOT/seeds"
|
||||||
|
|
||||||
|
local i name ip role work iso volid dns
|
||||||
|
for i in "${!VM_NAMES[@]}"; do
|
||||||
|
name=${VM_NAMES[$i]}
|
||||||
|
ip=${VM_IPS[$i]}
|
||||||
|
role=${VM_ROLES[$i]}
|
||||||
|
dns=$LAB_DC_IP # every lab VM resolves through the DC
|
||||||
|
|
||||||
|
work="$LAB_ROOT/seeds/$name"
|
||||||
|
rm -rf "$work"
|
||||||
|
mkdir -p "$work/norbourg/roles"
|
||||||
|
|
||||||
|
sed -e "s|@@HOSTNAME@@|${name}|g" \
|
||||||
|
-e "s|@@ADMIN_PASSWORD@@|${LAB_ADMIN_PASSWORD}|g" \
|
||||||
|
-e "s|@@IMAGE_INDEX@@|${WINDOWS_IMAGE_INDEX:-2}|g" \
|
||||||
|
"$tmpl" > "$work/Autounattend.xml"
|
||||||
|
|
||||||
|
cp "$payload/bootstrap.cmd" "$work/norbourg/"
|
||||||
|
cp "$payload/bootstrap.ps1" "$work/norbourg/"
|
||||||
|
|
||||||
|
cat > "$work/norbourg/config.ps1" <<EOF
|
||||||
|
\$Config = @{
|
||||||
|
Hostname = '${name}'
|
||||||
|
IP = '${ip}'
|
||||||
|
Prefix = ${LAB_NETMASK}
|
||||||
|
Gateway = '${LAB_GATEWAY}'
|
||||||
|
DNS = '${dns}'
|
||||||
|
Role = '${role}'
|
||||||
|
Domain = '${DOMAIN}'
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# A malformed answer file means a 20-minute silent install failure; catch it here.
|
||||||
|
python3 - "$work/Autounattend.xml" <<'PY' || die "rendered answer file is not valid XML for ${name}"
|
||||||
|
import sys, xml.etree.ElementTree as ET
|
||||||
|
ET.parse(sys.argv[1])
|
||||||
|
PY
|
||||||
|
|
||||||
|
iso="$LAB_ROOT/seeds/${name}-seed.iso"
|
||||||
|
volid="NRBG_${name^^}"
|
||||||
|
if have_cmd genisoimage; then
|
||||||
|
genisoimage -quiet -volid "$volid" -J -R -o "$iso" "$work"
|
||||||
|
else
|
||||||
|
xorriso -as mkisofs -quiet -V "$volid" -J -R -o "$iso" "$work"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ok "$(printf '%-6s %-14s %-4s %s' "$name" "$ip" "$role" "$iso")"
|
||||||
|
done
|
||||||
|
|
||||||
|
printf '\n'
|
||||||
|
ok "${#VM_NAMES[@]} seed ISO(s) in ${LAB_ROOT}/seeds"
|
||||||
|
}
|
||||||
@@ -79,6 +79,23 @@ load_vms() {
|
|||||||
(( ${#VM_NAMES[@]} > 0 )) || die "no VMs defined in VMS (lab.conf)"
|
(( ${#VM_NAMES[@]} > 0 )) || die "no VMs defined in VMS (lab.conf)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm_index() {
|
||||||
|
local name=$1 i
|
||||||
|
for i in "${!VM_NAMES[@]}"; do
|
||||||
|
if [[ ${VM_NAMES[$i]} == "$name" ]]; then
|
||||||
|
printf '%s\n' "$i"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Bash-native TCP probe: no nc dependency, 1 s timeout.
|
||||||
|
tcp_open() {
|
||||||
|
local host=$1 port=$2
|
||||||
|
timeout 1 bash -c "exec 3<>/dev/tcp/${host}/${port}" 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
sum_vm_ram_mb() {
|
sum_vm_ram_mb() {
|
||||||
local total=0 r
|
local total=0 r
|
||||||
for r in "${VM_RAM[@]}"; do total=$(( total + r )); done
|
for r in "${VM_RAM[@]}"; do total=$(( total + r )); done
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Norbourg lab — unattended install for Windows Server 2022 (eval).
|
||||||
|
Rendered by scripts/build_seed.sh; @@TOKENS@@ are substituted per VM.
|
||||||
|
|
||||||
|
Deliberately minimal: disk, locale, image, account, autologon and one
|
||||||
|
first-logon command. Static IP configuration happens in bootstrap.ps1
|
||||||
|
because the unattend TCPIP <Identifier> must match the adapter's connection
|
||||||
|
name exactly and fails silently when it does not.
|
||||||
|
-->
|
||||||
|
<unattend xmlns="urn:schemas-microsoft-com:unattend"
|
||||||
|
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
|
||||||
|
|
||||||
|
<settings pass="windowsPE">
|
||||||
|
<component name="Microsoft-Windows-International-Core-WinPE"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="31bf3856ad364e35"
|
||||||
|
language="neutral" versionScope="nonSxS">
|
||||||
|
<SetupUILanguage>
|
||||||
|
<UILanguage>en-US</UILanguage>
|
||||||
|
</SetupUILanguage>
|
||||||
|
<InputLocale>en-US</InputLocale>
|
||||||
|
<SystemLocale>en-US</SystemLocale>
|
||||||
|
<UILanguage>en-US</UILanguage>
|
||||||
|
<UserLocale>en-US</UserLocale>
|
||||||
|
</component>
|
||||||
|
|
||||||
|
<component name="Microsoft-Windows-Setup"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="31bf3856ad364e35"
|
||||||
|
language="neutral" versionScope="nonSxS">
|
||||||
|
<DiskConfiguration>
|
||||||
|
<Disk wcm:action="add">
|
||||||
|
<DiskID>0</DiskID>
|
||||||
|
<WillWipeDisk>true</WillWipeDisk>
|
||||||
|
<CreatePartitions>
|
||||||
|
<CreatePartition wcm:action="add">
|
||||||
|
<Order>1</Order>
|
||||||
|
<Type>Primary</Type>
|
||||||
|
<Size>500</Size>
|
||||||
|
</CreatePartition>
|
||||||
|
<CreatePartition wcm:action="add">
|
||||||
|
<Order>2</Order>
|
||||||
|
<Type>Primary</Type>
|
||||||
|
<Extend>true</Extend>
|
||||||
|
</CreatePartition>
|
||||||
|
</CreatePartitions>
|
||||||
|
<ModifyPartitions>
|
||||||
|
<ModifyPartition wcm:action="add">
|
||||||
|
<Order>1</Order>
|
||||||
|
<PartitionID>1</PartitionID>
|
||||||
|
<Active>true</Active>
|
||||||
|
<Format>NTFS</Format>
|
||||||
|
<Label>System</Label>
|
||||||
|
</ModifyPartition>
|
||||||
|
<ModifyPartition wcm:action="add">
|
||||||
|
<Order>2</Order>
|
||||||
|
<PartitionID>2</PartitionID>
|
||||||
|
<Format>NTFS</Format>
|
||||||
|
<Label>Windows</Label>
|
||||||
|
<Letter>C</Letter>
|
||||||
|
</ModifyPartition>
|
||||||
|
</ModifyPartitions>
|
||||||
|
</Disk>
|
||||||
|
<WillShowUI>OnError</WillShowUI>
|
||||||
|
</DiskConfiguration>
|
||||||
|
|
||||||
|
<ImageInstall>
|
||||||
|
<OSImage>
|
||||||
|
<InstallFrom>
|
||||||
|
<MetaData wcm:action="add">
|
||||||
|
<Key>/IMAGE/INDEX</Key>
|
||||||
|
<Value>@@IMAGE_INDEX@@</Value>
|
||||||
|
</MetaData>
|
||||||
|
</InstallFrom>
|
||||||
|
<InstallTo>
|
||||||
|
<DiskID>0</DiskID>
|
||||||
|
<PartitionID>2</PartitionID>
|
||||||
|
</InstallTo>
|
||||||
|
</OSImage>
|
||||||
|
</ImageInstall>
|
||||||
|
|
||||||
|
<UserData>
|
||||||
|
<AcceptEula>true</AcceptEula>
|
||||||
|
<FullName>Norbourg</FullName>
|
||||||
|
<Organization>Norbourg Services Financiers</Organization>
|
||||||
|
</UserData>
|
||||||
|
</component>
|
||||||
|
</settings>
|
||||||
|
|
||||||
|
<settings pass="specialize">
|
||||||
|
<component name="Microsoft-Windows-Shell-Setup"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="31bf3856ad364e35"
|
||||||
|
language="neutral" versionScope="nonSxS">
|
||||||
|
<ComputerName>@@HOSTNAME@@</ComputerName>
|
||||||
|
<TimeZone>Eastern Standard Time</TimeZone>
|
||||||
|
<RegisteredOwner>Norbourg</RegisteredOwner>
|
||||||
|
<RegisteredOrganization>Norbourg Services Financiers</RegisteredOrganization>
|
||||||
|
</component>
|
||||||
|
|
||||||
|
<component name="Microsoft-Windows-ServerManager-SvrMgrNc"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="31bf3856ad364e35"
|
||||||
|
language="neutral" versionScope="nonSxS">
|
||||||
|
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
|
||||||
|
</component>
|
||||||
|
|
||||||
|
<component name="Microsoft-Windows-IE-ESC"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="31bf3856ad364e35"
|
||||||
|
language="neutral" versionScope="nonSxS">
|
||||||
|
<IEHardenAdmin>false</IEHardenAdmin>
|
||||||
|
<IEHardenUser>false</IEHardenUser>
|
||||||
|
</component>
|
||||||
|
</settings>
|
||||||
|
|
||||||
|
<settings pass="oobeSystem">
|
||||||
|
<component name="Microsoft-Windows-International-Core"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="31bf3856ad364e35"
|
||||||
|
language="neutral" versionScope="nonSxS">
|
||||||
|
<InputLocale>en-US</InputLocale>
|
||||||
|
<SystemLocale>en-US</SystemLocale>
|
||||||
|
<UILanguage>en-US</UILanguage>
|
||||||
|
<UserLocale>en-US</UserLocale>
|
||||||
|
</component>
|
||||||
|
|
||||||
|
<component name="Microsoft-Windows-Shell-Setup"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
publicKeyToken="31bf3856ad364e35"
|
||||||
|
language="neutral" versionScope="nonSxS">
|
||||||
|
<OOBE>
|
||||||
|
<HideEULAPage>true</HideEULAPage>
|
||||||
|
<HideLocalAccountScreen>true</HideLocalAccountScreen>
|
||||||
|
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
|
||||||
|
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
|
||||||
|
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
|
||||||
|
<NetworkLocation>Work</NetworkLocation>
|
||||||
|
<ProtectYourPC>3</ProtectYourPC>
|
||||||
|
<SkipMachineOOBE>true</SkipMachineOOBE>
|
||||||
|
<SkipUserOOBE>true</SkipUserOOBE>
|
||||||
|
</OOBE>
|
||||||
|
|
||||||
|
<UserAccounts>
|
||||||
|
<AdministratorPassword>
|
||||||
|
<Value>@@ADMIN_PASSWORD@@</Value>
|
||||||
|
<PlainText>true</PlainText>
|
||||||
|
</AdministratorPassword>
|
||||||
|
</UserAccounts>
|
||||||
|
|
||||||
|
<AutoLogon>
|
||||||
|
<Enabled>true</Enabled>
|
||||||
|
<LogonCount>3</LogonCount>
|
||||||
|
<Username>Administrator</Username>
|
||||||
|
<Password>
|
||||||
|
<Value>@@ADMIN_PASSWORD@@</Value>
|
||||||
|
<PlainText>true</PlainText>
|
||||||
|
</Password>
|
||||||
|
</AutoLogon>
|
||||||
|
|
||||||
|
<FirstLogonCommands>
|
||||||
|
<SynchronousCommand wcm:action="add">
|
||||||
|
<Order>1</Order>
|
||||||
|
<Description>Norbourg bootstrap</Description>
|
||||||
|
<CommandLine>cmd /c for %d in (D E F G H I J K) do if exist %d:\norbourg\bootstrap.cmd call %d:\norbourg\bootstrap.cmd</CommandLine>
|
||||||
|
<RequiresUserInput>false</RequiresUserInput>
|
||||||
|
</SynchronousCommand>
|
||||||
|
</FirstLogonCommands>
|
||||||
|
</component>
|
||||||
|
</settings>
|
||||||
|
|
||||||
|
</unattend>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@echo off
|
||||||
|
rem Norbourg lab — first-logon entry point (runs from the seed ISO).
|
||||||
|
if not exist C:\norbourg mkdir C:\norbourg
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0bootstrap.ps1" >> C:\norbourg\bootstrap.log 2>&1
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# Norbourg lab — first-boot bootstrap, runs once from the seed ISO.
|
||||||
|
# The unattend file creates the account and triggers this; everything that
|
||||||
|
# touches the network happens here because unattend TCPIP settings fail
|
||||||
|
# silently when the adapter name does not match.
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$base = 'C:\norbourg'
|
||||||
|
New-Item -ItemType Directory -Force -Path $base | Out-Null
|
||||||
|
Start-Transcript -Path "$base\bootstrap.log" -Append | Out-Null
|
||||||
|
|
||||||
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
|
. (Join-Path $here 'config.ps1')
|
||||||
|
|
||||||
|
Write-Host "bootstrap: host=$($Config.Hostname) role=$($Config.Role) ip=$($Config.IP)"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ network
|
||||||
|
$nic = Get-NetAdapter |
|
||||||
|
Where-Object { $_.Status -eq 'Up' -and $_.InterfaceDescription -notmatch 'Loopback' } |
|
||||||
|
Select-Object -First 1
|
||||||
|
|
||||||
|
if (-not $nic) {
|
||||||
|
Write-Host 'bootstrap: no up adapter, network step skipped'
|
||||||
|
} else {
|
||||||
|
Remove-NetIPAddress -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
|
||||||
|
Remove-NetRoute -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
New-NetIPAddress -InterfaceIndex $nic.ifIndex `
|
||||||
|
-IPAddress $Config.IP -PrefixLength $Config.Prefix `
|
||||||
|
-DefaultGateway $Config.Gateway | Out-Null
|
||||||
|
|
||||||
|
Set-DnsClientServerAddress -InterfaceIndex $nic.ifIndex -ServerAddresses $Config.DNS
|
||||||
|
Set-NetConnectionProfile -InterfaceIndex $nic.ifIndex -NetworkCategory Private -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
Write-Host "bootstrap: $($nic.Name) -> $($Config.IP)/$($Config.Prefix)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ WinRM
|
||||||
|
# The host provisions over WinRM; no guest agent needed for that.
|
||||||
|
Enable-PSRemoting -SkipNetworkProfileCheck -Force | Out-Null
|
||||||
|
Set-NetFirewallRule -DisplayGroup 'Windows Remote Management' -Enabled True -Profile Any -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
# RDP: useful for the instructor when a step misbehaves.
|
||||||
|
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Terminal Server' `
|
||||||
|
-Name fDenyTSConnections -Value 0
|
||||||
|
Enable-NetFirewallRule -DisplayGroup 'Remote Desktop' -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ marker
|
||||||
|
"$env:COMPUTERNAME|$($Config.Role)|$($Config.IP)|$((Get-Date).ToString('s'))" |
|
||||||
|
Set-Content -Path "$base\stamp.txt" -Encoding ascii
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ role
|
||||||
|
$role = Join-Path $here "roles\$($Config.Role).ps1"
|
||||||
|
if (Test-Path $role) {
|
||||||
|
Write-Host "bootstrap: running role $($Config.Role)"
|
||||||
|
& $role
|
||||||
|
} else {
|
||||||
|
Write-Host "bootstrap: no role script for '$($Config.Role)' yet (phase 5)"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host 'bootstrap: done'
|
||||||
|
Stop-Transcript | Out-Null
|
||||||
Reference in New Issue
Block a user