Files
mtusi2026lab7/scripts/reset.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

22 lines
1.4 KiB
PowerShell

# Windows PowerShell 5.1+ version of scripts/reset.sh: INTENTIONAL deletion of lab7 data (asks for confirmation).
# Removes all project volumes (PostgreSQL, S3, NATS, OpenBao raft+audit, Prometheus/Loki/Tempo/Grafana), the OpenBao
# operator material (it belongs to the deleted storage) and issued role_id/SecretID (secrets\bao). PKI and passwords in
# secrets\ are kept; the next scripts\up.ps1 initializes OpenBao again. Normal stop without data loss:
# docker compose --env-file .env --profile ttl --profile fault --profile tools --profile tests down --remove-orphans
# powershell -NoProfile -ExecutionPolicy Bypass -File scripts\reset.ps1 [-Force]
param([switch]$Force)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
Set-Location $root
$op = $env:MTUSI_OPERATOR_DIR
if (-not $op) { $op = Join-Path $env:USERPROFILE '.mtusi-lab7-operator' }
if (-not $Force) {
$ans = Read-Host "Delete ALL lab7 data (volumes, $op\openbao-init.json, secrets\bao)? Type yes"
if ($ans -ne 'yes') { Write-Output 'cancelled'; exit 1 }
}
& docker compose --env-file .env --profile ttl --profile fault --profile tools --profile tests down -v --remove-orphans
if ($LASTEXITCODE -ne 0) { throw 'docker compose down -v failed' }
Remove-Item -Force -ErrorAction SilentlyContinue (Join-Path $op 'openbao-init.json')
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'secrets\bao'
Write-Output 'data deleted; start again: scripts\up.ps1'