the-custodian/docs/changes/CUST-WP-0073/workstation-agents-r4/import.ps1
codex 15b217c34d
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Reject generated-only commits / generated-commit-guard (push) Successful in 9s
CUST-WP-0073: record 2026-10-20 interview, owner deliveries, r4 workstation recipe and attended runbook
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 20:36:27 +02:00

20 lines
1.3 KiB
PowerShell

# CUST-WP-0073 r4 — attended only. Creates the NEW distro custodian-agents; touches no existing distro.
param([switch]$IAmAttended)
$ErrorActionPreference = 'Stop'
if (-not $IAmAttended) { throw 'REFUSED: run with -IAmAttended in an attended window.' }
$DistroName = 'custodian-agents'
$Url = 'https://releases.ubuntu.com/24.04.5/ubuntu-24.04.5-wsl-amd64.wsl'
$Expected = 'bb415d824822c4b878125729af451a5d18fb13d1cf5cbed9a7393ad64ac6039e'
$Base = Join-Path $env:LOCALAPPDATA 'Custodian\WSL'
$Store = Join-Path $Base $DistroName
$Image = Join-Path $Base 'ubuntu-24.04.5-wsl-amd64.wsl'
$Existing = ((& wsl.exe --list --quiet) -replace "`0", '') -split "`r?`n" | ForEach-Object { $_.Trim() }
if ($Existing -contains $DistroName) { throw 'Distribution already exists' }
if (Test-Path -LiteralPath $Store) { throw 'Destination already exists' }
New-Item -ItemType Directory -Force -Path $Base | Out-Null
if (-not (Test-Path -LiteralPath $Image)) { Invoke-WebRequest -Uri $Url -OutFile $Image -UseBasicParsing }
$Actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $Image).Hash.ToLower()
if ($Actual -ne $Expected) { throw "Rootfs digest mismatch: $Actual" }
& wsl.exe --import $DistroName $Store $Image --version 2
if ($LASTEXITCODE -ne 0) { throw 'Import failed; retain evidence, do not unregister' }
Write-Output "imported $DistroName sha256=$Actual store=$Store"