Replace the V6.0 captured-binary replay (pf-x86-MitutoyoApp.zip + c-MitutoyoApp.zip + hklm-wow-mitutoyo.reg.gz) with a real vendor install from FORMTRACEPAK-V6.213.iso mounted via Mount-DiskImage. 09-Setup-WaxAndTrace.ps1: - Step 2 rewritten: Mount-DiskImage on C:\WaxTrace-Install\formtracepak\FORMTRACEPAK-V6.213.iso, run the VB6 Setup.exe wrapper from the assigned drive letter (DRIVE_CDROM check satisfied by virtual mount, no real CD needed), then Dismount. - Header rewritten: drop captured/ description, note legacy fallback remains in the repo (captured-binary/ unchanged) for manual recovery if the v6.213 vendor install fails on a bay. sync-waxtrace.sh: - Push formtracepak/FORMTRACEPAK-V6.213.iso (2.0 GB) into the bundle instead of captured/ payload. Override path via $FTPAK_ISO env var if needed (e.g. testing a v6.213 patch ISO). - Sanity check no longer demands pf-x86-MitutoyoApp.zip; only requires prereqs/ + the manifest + dispatcher PS1. playbook/utilities/convert-cal-iso.sh: - New helper. Rebuilds a Linux-dd of a multi-session UDF cal disc into a clean ISO9660+UDF hybrid that Windows Mount-DiskImage reads. mkisofs reads the file via loop-udf, repacks single-session with the asset tag as volume label. Run when `file CAL-*.iso` reports "data" (multi-session UDF dd produced a Linux-readable but Windows-unreadable container). Single-session 218-458A discs from dd are already ISO9660 and don't need this. Verified on win11 VM via qga: V6.213 ISO mounts, Setup.exe locatable. 14 cal ISOs all converted to ISO9660 (md5s refreshed in INDEX.csv), re-synced to /srv/samba/enrollment/installers-post/waxtrace/calibrations/. PXE share bundle now 2.0 GB total (V6.213 ISO + 14 cal ISOs + prereqs). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
211 lines
10 KiB
PowerShell
211 lines
10 KiB
PowerShell
# 09-Setup-WaxAndTrace.ps1 - Wax and Trace pc-type setup (Mitutoyo FormTracePak v6.213)
|
|
#
|
|
# Imaging-time install. Installs prereqs from manifest, then runs the
|
|
# Mitutoyo FormTracePak v6.213 vendor installer from a mounted ISO. The
|
|
# VB6 Setup.exe wrapper checks GetDriveType() == DRIVE_CDROM; Mount-DiskImage
|
|
# satisfies that (a real CD drive isn't required). Per-asset calibration ISO
|
|
# applies last.
|
|
#
|
|
# Layout at C:\WaxTrace-Install\ (xcopied by startnet.cmd):
|
|
# waxtrace-manifest.json
|
|
# 09-Setup-WaxAndTrace.ps1 (this file)
|
|
# prereqs\vcredist_x86.exe (VC++ 2008 x86)
|
|
# prereqs\vcredist_x64.exe (VC++ 2008 x64)
|
|
# prereqs\vc_redist.x86.exe (VC++ 2017 x86)
|
|
# prereqs\vc_redist.x64.exe (VC++ 2017 x64)
|
|
# prereqs\HASPUserSetup.exe (Sentinel Runtime / HASP dongle driver)
|
|
# formtracepak\FORMTRACEPAK-V6.213.iso (vendor installer ISO, ~2 GB)
|
|
# calibrations\CAL-<asset>_serial-<sn>_probe-<probe>.iso (per-machine)
|
|
#
|
|
# Per-machine calibration is applied separately (mount cal ISO + run its
|
|
# Setup.exe), keyed by C:\Enrollment\machine-number.txt.
|
|
#
|
|
# Legacy captured/ replay path (V6.0 zip + reg) retired 2026-05-21. The
|
|
# captured-binary/ payload is still in the repo as a fallback - if the
|
|
# v6.213 vendor install fails on a bay, fall back to the captured path
|
|
# manually. See git history for the prior shape.
|
|
#
|
|
# Log: C:\Logs\WaxTrace\09-Setup-WaxAndTrace.log
|
|
# C:\Logs\WaxTrace\install.log (written by Install-FromManifest)
|
|
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
# Mirror the CMM pattern (09-Setup-CMM.ps1): the script itself lives in the
|
|
# shopfloor-setup tree (xcopied during WinPE), but the bulky bootstrap bundle
|
|
# (prereqs + captured master + cal ISOs) lives at C:\WaxTrace-Install\, put
|
|
# there by startnet.cmd from Y:\installers-post\waxtrace\ at imaging time.
|
|
$stagingRoot = 'C:\WaxTrace-Install'
|
|
$manifestPath = Join-Path $stagingRoot 'waxtrace-manifest.json'
|
|
$libSource = Join-Path $PSScriptRoot '..\common\lib\Install-FromManifest.ps1'
|
|
|
|
$logDir = 'C:\Logs\WaxTrace'
|
|
$installLog = Join-Path $logDir 'install.log'
|
|
$transcriptLog = Join-Path $logDir '09-Setup-WaxAndTrace.log'
|
|
|
|
if (-not (Test-Path $logDir)) {
|
|
New-Item -Path $logDir -ItemType Directory -Force | Out-Null
|
|
}
|
|
|
|
try { Start-Transcript -Path $transcriptLog -Append -Force | Out-Null } catch {}
|
|
|
|
function Write-WTLog {
|
|
param([string]$Message, [string]$Level = 'INFO')
|
|
$stamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
Write-Host "[$stamp] [$Level] $Message"
|
|
}
|
|
|
|
Write-WTLog "================================================================"
|
|
Write-WTLog "=== WaxTrace Setup (imaging-time) session start (PID $PID) ==="
|
|
Write-WTLog "Running as: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
|
|
Write-WTLog "Script root: $PSScriptRoot"
|
|
Write-WTLog "================================================================"
|
|
|
|
# Status push - best-effort.
|
|
$pxeStatusLib = Join-Path $PSScriptRoot '..\Shopfloor\lib\Send-PxeStatus.ps1'
|
|
if (Test-Path $pxeStatusLib) {
|
|
try { . $pxeStatusLib; Send-PxeStatus -Stage '09-Setup-WaxAndTrace: starting' -StageIndex 3 -StageTotal 8 } catch { }
|
|
}
|
|
|
|
foreach ($file in @('pc-type.txt','machine-number.txt')) {
|
|
$path = "C:\Enrollment\$file"
|
|
if (Test-Path -LiteralPath $path) {
|
|
$content = (Get-Content -LiteralPath $path -First 1 -ErrorAction SilentlyContinue).Trim()
|
|
Write-WTLog " $file = $content"
|
|
} else {
|
|
Write-WTLog " $file = (not present)"
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 1: Prereqs via manifest (VC++ 2008 + 2017, HASP/Sentinel)
|
|
# ============================================================================
|
|
if (-not (Test-Path $manifestPath)) {
|
|
Write-WTLog "waxtrace-manifest.json not found at $manifestPath" 'ERROR'
|
|
} elseif (-not (Test-Path $libSource)) {
|
|
Write-WTLog "Install-FromManifest.ps1 not found at $libSource" 'ERROR'
|
|
} else {
|
|
Write-WTLog "Running Install-FromManifest (InstallerRoot=$PSScriptRoot)"
|
|
& $libSource -ManifestPath $manifestPath -InstallerRoot $stagingRoot -LogFile $installLog
|
|
$rc = $LASTEXITCODE
|
|
Write-WTLog "Install-FromManifest returned $rc"
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 2: FormTracePak v6.213 vendor install (Mount-DiskImage + Setup.exe)
|
|
# ============================================================================
|
|
# Detection: skip if Formtracepak already present (re-run safe).
|
|
$ftpakExe = 'C:\Program Files (x86)\MitutoyoApp\Formtracepak\Formtracepak.exe'
|
|
if (Test-Path -LiteralPath $ftpakExe) {
|
|
Write-WTLog "Formtracepak.exe already present - skipping vendor install"
|
|
} else {
|
|
$ftpakIso = Join-Path $stagingRoot 'formtracepak\FORMTRACEPAK-V6.213.iso'
|
|
if (-not (Test-Path -LiteralPath $ftpakIso)) {
|
|
Write-WTLog "FormTracePak ISO not found at $ftpakIso" 'ERROR'
|
|
} else {
|
|
Write-WTLog "Mounting FormTracePak ISO: $ftpakIso"
|
|
try {
|
|
$img = Mount-DiskImage -ImagePath $ftpakIso -PassThru -ErrorAction Stop
|
|
Start-Sleep -Seconds 8
|
|
$vol = Get-DiskImage -ImagePath $ftpakIso | Get-Volume
|
|
$ftpakDrive = $vol.DriveLetter
|
|
if (-not $ftpakDrive) {
|
|
Write-WTLog " Mount succeeded but no drive letter assigned" 'ERROR'
|
|
} else {
|
|
Write-WTLog " mounted at ${ftpakDrive}: (volume label=$($vol.FileSystemLabel))"
|
|
$setupExe = "${ftpakDrive}:\Setup.exe"
|
|
if (-not [System.IO.File]::Exists($setupExe)) {
|
|
Write-WTLog " Setup.exe not found at $setupExe" 'ERROR'
|
|
} else {
|
|
Write-WTLog " running $setupExe (VB6 wrapper - requires DRIVE_CDROM)"
|
|
# Setup.exe is the VB6 wrapper. /silent + /qn flags often
|
|
# ignored - the wrapper drives appSetup.exe + msiexec from
|
|
# its own UI. If the wrapper insists on interactive, a tech
|
|
# at the bay clicks through. Acceptable today; quieter
|
|
# path is a future improvement (drive msiexec direct on
|
|
# the wrapper's bundled MSIs).
|
|
try {
|
|
$p = Start-Process -FilePath $setupExe `
|
|
-WorkingDirectory "${ftpakDrive}:\" `
|
|
-ArgumentList '/silent' `
|
|
-Wait -PassThru
|
|
Write-WTLog " Setup.exe exit $($p.ExitCode)"
|
|
} catch {
|
|
Write-WTLog " Setup.exe failed: $_" 'ERROR'
|
|
}
|
|
}
|
|
}
|
|
Dismount-DiskImage -ImagePath $ftpakIso -ErrorAction SilentlyContinue | Out-Null
|
|
Write-WTLog " FormTracePak ISO dismounted"
|
|
} catch {
|
|
Write-WTLog " Mount-DiskImage failed: $_" 'ERROR'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 3: Per-machine calibration ISO (mount + apply via cal Setup.exe)
|
|
# ============================================================================
|
|
# Cal ISOs are keyed by asset_tag. Read machine-number.txt to pick the right
|
|
# ISO. Each cal ISO is ~1.7MB and contains a tiny Mitutoyo wrapper Setup.exe
|
|
# plus data/*.txt compensation tables for the bay's specific probe + serial.
|
|
$mnPath = 'C:\Enrollment\machine-number.txt'
|
|
$asset = $null
|
|
if (Test-Path -LiteralPath $mnPath) {
|
|
$asset = (Get-Content -LiteralPath $mnPath -First 1 -ErrorAction SilentlyContinue).Trim()
|
|
}
|
|
if (-not $asset) {
|
|
Write-WTLog "machine-number.txt missing or empty - skipping calibration apply" 'WARN'
|
|
} else {
|
|
$calDir = Join-Path $stagingRoot 'calibrations'
|
|
$candidate = Get-ChildItem $calDir -Filter "CAL-${asset}_*.iso" -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if (-not $candidate) {
|
|
Write-WTLog "No cal ISO matched CAL-${asset}_*.iso in $calDir - skipping" 'WARN'
|
|
} else {
|
|
Write-WTLog "Mounting cal ISO: $($candidate.FullName)"
|
|
try {
|
|
$img = Mount-DiskImage -ImagePath $candidate.FullName -PassThru -ErrorAction Stop
|
|
Start-Sleep -Seconds 2
|
|
$calDrive = ($img | Get-Volume).DriveLetter
|
|
Write-WTLog " mounted at ${calDrive}:"
|
|
$calSetup = "${calDrive}:\Setup.exe"
|
|
if (Test-Path -LiteralPath $calSetup) {
|
|
Write-WTLog " running cal Setup.exe (may prompt - VB6 wrapper, same vintage as main installer)"
|
|
# Cal ISO Setup.exe is tiny (135KB) - if it prompts, user has to click through.
|
|
# Acceptable today; future: dark-deploy the data/*.txt files directly into
|
|
# the FormTracePak data dir + skip Setup.exe.
|
|
$p = Start-Process -FilePath $calSetup -WorkingDirectory "${calDrive}:\" -Wait -PassThru
|
|
Write-WTLog " cal Setup.exe exit $($p.ExitCode)"
|
|
} else {
|
|
Write-WTLog " cal Setup.exe not found on ISO at $calSetup" 'WARN'
|
|
}
|
|
Dismount-DiskImage -ImagePath $candidate.FullName -ErrorAction SilentlyContinue | Out-Null
|
|
Write-WTLog " cal ISO dismounted"
|
|
} catch {
|
|
Write-WTLog " Mount-DiskImage failed: $_" 'ERROR'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# Step 4: OpenText auto-start at login (HostExplorer "WJ Shopfloor" session)
|
|
# ============================================================================
|
|
$autoStartLib = Join-Path $PSScriptRoot '..\Shopfloor\lib\Set-OpenTextAutoStart.ps1'
|
|
if (Test-Path -LiteralPath $autoStartLib) {
|
|
Write-WTLog "Calling $autoStartLib"
|
|
& $autoStartLib
|
|
} else {
|
|
Write-WTLog "Set-OpenTextAutoStart.ps1 not found at $autoStartLib - OpenText auto-start NOT configured" 'WARN'
|
|
}
|
|
|
|
if (Get-Command Send-PxeStatus -ErrorAction SilentlyContinue) {
|
|
$finalStatus = if ($rc -eq 0) { 'in_progress' } else { 'failed' }
|
|
$finalErr = if ($rc -ne 0) { "Install-FromManifest exit $rc" } else { '' }
|
|
Send-PxeStatus -Stage '09-Setup-WaxAndTrace: complete' -StageIndex 4 -StageTotal 8 -Status $finalStatus -Error_ $finalErr
|
|
}
|
|
|
|
Write-WTLog "================================================================"
|
|
Write-WTLog "=== WaxTrace Setup session end ==="
|
|
Write-WTLog "================================================================"
|
|
|
|
try { Stop-Transcript | Out-Null } catch {}
|