Files
mtusi2026lab7/scripts/up.ps1
T
sendormeco d15f2a3631
Application stack (lab7) / stack (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
7 — Т2302 — ебедев — на 5
2026-11-22 23:26:17 +03:00

28 lines
1.7 KiB
PowerShell

# 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\<svc>), 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)'