# Windows PowerShell 5.1+ version of scripts/up.sh (lab7, operator): build, OpenBao start -> init (first time) -> # unseal -> bootstrap (policies/AppRole/KV, role_id+SecretID into secrets\bao\), then all services (--wait). # Operator material (unseal shares, root token) is kept in %USERPROFILE%\.mtusi-lab7-operator, never printed. # powershell -NoProfile -ExecutionPolicy Bypass -File scripts\up.ps1 [-Profiles ttl] param([string[]]$Profiles = @()) $ErrorActionPreference = 'Stop' $root = Split-Path -Parent $PSScriptRoot Set-Location $root $env:NO_PROXY = '127.0.0.1,localhost' $env:PYTHONUTF8 = '1' if (-not (Test-Path 'secrets\tls\trust\ca.crt')) { throw 'no secrets\tls: run scripts\init-secrets.ps1 first' } $pyApp = Get-Command py -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 $pythonApp = Get-Command python -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 if ($pyApp) { $py = $pyApp.Source; $pre = @('-3') } elseif ($pythonApp) { $py = $pythonApp.Source; $pre = @() } else { throw 'Python 3.9+ not found' } function Dc { & docker compose --env-file .env @args; if ($LASTEXITCODE -ne 0) { throw ('docker compose ' + ($args -join ' ') + ' failed') } } function Bao { & $py @pre scripts\bao_admin.py @args; if ($LASTEXITCODE -ne 0) { throw ('bao_admin ' + ($args -join ' ') + ' failed') } } Dc build -q Dc up -d openbao Bao wait --timeout 90 Bao init Bao unseal Bao bootstrap $pargs = @(); foreach ($p in $Profiles) { $pargs += @('--profile', $p) } Dc @pargs up -d --wait --wait-timeout 300 & docker compose --env-file .env ps --format 'table {{.Service}}\t{{.Status}}\t{{.Ports}}' Write-Output 'ready: https://127.0.0.1:8443 (CA: secrets\tls\trust\ca.crt)'