# 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() # shared_data_dir may legitimately contain spaces (e.g. CMM8 "Venture CMM8"). # Trim() strips only leading/trailing whitespace, never internal spaces. $sharedDataDir = '' if ($match.PSObject.Properties['shared_data_dir'] -and $match.shared_data_dir) { $sharedDataDir = $match.shared_data_dir.Trim() } [System.IO.File]::WriteAllText((Join-Path $OutDir 'version.txt'), $version) [System.IO.File]::WriteAllText((Join-Path $OutDir 'doda.txt'), $doda) if ($sharedDataDir) { [System.IO.File]::WriteAllText((Join-Path $OutDir 'shareddatadir.txt'), $sharedDataDir) } Write-Host "Resolved $CmmId -> PC-DMIS $version, DODA=$doda, SharedDataDir=$(if ($sharedDataDir) { $sharedDataDir } else { '(none)' })" Write-Host " version.txt -> $OutDir\version.txt" Write-Host " doda.txt -> $OutDir\doda.txt" if ($sharedDataDir) { Write-Host " shareddatadir.txt -> $OutDir\shareddatadir.txt" } exit 0