sync-cmm-backups.sh pushes per-CMM backup sets (goCMM + PC-DMIS zips produced by Backup-CMM) from pxe-images/cmm-bk/<cmm_id>/ to the PXE share at installers-post/cmm/backups/<cmm_id>/, atomic-swap with a timestamped prior copy. Distinct from sync-cmm.sh (which stages the CMM installer bundle). resolve-cmm-bay-config.ps1 now also writes cmmid.txt alongside version/doda/ partgroup, so 09-Setup-CMM can locate this bay's staged backup for restore-by-machine-number. The 09-Setup-CMM restore block + startnet staging line are intentionally NOT added yet - the restore needs manual end-to-end validation on a real CMM before auto-running at imaging (per the live-bay restore issues we hit). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
66 lines
2.4 KiB
PowerShell
66 lines
2.4 KiB
PowerShell
# resolve-cmm-bay-config.ps1 - Resolve CMM bay config from cmm-bay-config.csv.
|
|
#
|
|
# Called by startnet.cmd after the bay picker. Reads the CSV from the PXE
|
|
# enrollment share, looks up the selected CMM ID, and writes:
|
|
# W:\Enrollment\cmm\version.txt (e.g. "2019")
|
|
# W:\Enrollment\cmm\doda.txt (e.g. "yes" or "no")
|
|
#
|
|
# 09-Setup-CMM.ps1 reads these at install time to gate which PC-DMIS
|
|
# version gets installed and whether DODA is deployed.
|
|
|
|
param(
|
|
[Parameter(Mandatory=$true)][string]$ConfigPath,
|
|
[Parameter(Mandatory=$true)][string]$CmmId,
|
|
[Parameter(Mandatory=$true)][string]$OutDir
|
|
)
|
|
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
if (-not (Test-Path -LiteralPath $ConfigPath)) {
|
|
Write-Host "ERROR: CSV not found at $ConfigPath"
|
|
exit 1
|
|
}
|
|
|
|
try {
|
|
$bays = Import-Csv -LiteralPath $ConfigPath
|
|
} catch {
|
|
Write-Host "ERROR: Failed to parse $ConfigPath - $_"
|
|
exit 1
|
|
}
|
|
|
|
$match = $bays | Where-Object { $_.cmm_id -ieq $CmmId }
|
|
if (-not $match) {
|
|
Write-Host "WARNING: $CmmId not found in bay-config. No version/doda resolution."
|
|
exit 0
|
|
}
|
|
|
|
if (-not (Test-Path $OutDir)) {
|
|
New-Item -Path $OutDir -ItemType Directory -Force | Out-Null
|
|
}
|
|
|
|
$version = $match.pcdmis_version.Trim()
|
|
$doda = $match.doda.Trim().ToLower()
|
|
# part_group is the goCMM "Selected Part Group" path. It may legitimately
|
|
# contain spaces (e.g. CMM8 "Venture CMM8"); Trim() strips only leading/
|
|
# trailing whitespace, never internal spaces. Stored in the friendly S:\
|
|
# form; 09-Setup-CMM converts it to the tsgwp00525 UNC at apply time.
|
|
$partGroup = ''
|
|
if ($match.PSObject.Properties['part_group'] -and $match.part_group) {
|
|
$partGroup = $match.part_group.Trim()
|
|
}
|
|
|
|
[System.IO.File]::WriteAllText((Join-Path $OutDir 'version.txt'), $version)
|
|
[System.IO.File]::WriteAllText((Join-Path $OutDir 'doda.txt'), $doda)
|
|
# cmmid.txt: the resolved CMM id, so 09-Setup-CMM can locate this bay's staged
|
|
# backup set (installers-post\cmm\backups\<cmm_id>\) for restore-by-machine-#.
|
|
[System.IO.File]::WriteAllText((Join-Path $OutDir 'cmmid.txt'), $CmmId)
|
|
if ($partGroup) {
|
|
[System.IO.File]::WriteAllText((Join-Path $OutDir 'partgroup.txt'), $partGroup)
|
|
}
|
|
|
|
Write-Host "Resolved $CmmId -> PC-DMIS $version, DODA=$doda, PartGroup=$(if ($partGroup) { $partGroup } else { '(none)' })"
|
|
Write-Host " version.txt -> $OutDir\version.txt"
|
|
Write-Host " doda.txt -> $OutDir\doda.txt"
|
|
if ($partGroup) { Write-Host " partgroup.txt -> $OutDir\partgroup.txt" }
|
|
exit 0
|