Eliminate USB requirement for WinPE PXE boot, add image upload script
- Add startnet.cmd: FlatSetupLoader.exe + Boot.tag/Media.tag eliminates physical USB requirement for WinPE PXE deployment - Add Upload-Image.ps1: PowerShell script to robocopy MCL cached images to PXE server via SMB (Deploy, Tools, Sources) - Add gea-shopfloor-mce image type across playbook, webapp, startnet - Change webapp import to move (not copy) for upload sources to save disk - Add Samba symlink following config for shared image directories - Add Media.tag creation task in playbook for drive detection - Update prepare-boot-tools.sh with Blancco config/initramfs patching - Add grub-efi-amd64-bin to download-packages.sh Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
164
Upload-Image.ps1
Normal file
164
Upload-Image.ps1
Normal file
@@ -0,0 +1,164 @@
|
||||
#
|
||||
# Upload-Image.ps1 — Copy Media Creator Lite cached image to the PXE server
|
||||
#
|
||||
# Copies Deploy/, Tools/, and Sources (from Boot/Sources.zip) to the
|
||||
# PXE server's image-upload share using robocopy with authentication.
|
||||
#
|
||||
# Usage:
|
||||
# .\Upload-Image.ps1 (uses default MCL cache path)
|
||||
# .\Upload-Image.ps1 -CachePath "D:\MCL\Cache" (custom cache location)
|
||||
# .\Upload-Image.ps1 -Server 10.9.100.1 (custom server IP)
|
||||
#
|
||||
# After upload, use the PXE webapp (http://10.9.100.1:9009) to import
|
||||
# the uploaded content into the desired image type.
|
||||
#
|
||||
|
||||
param(
|
||||
[string]$CachePath = "C:\ProgramData\GEAerospace\MediaCreator\Cache",
|
||||
[string]$Server = "10.9.100.1",
|
||||
[string]$User = "pxe-upload",
|
||||
[string]$Pass = "pxe",
|
||||
[switch]$IncludeDell10
|
||||
)
|
||||
|
||||
$Share = "\\$Server\image-upload"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " PXE Server Image Uploader" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# --- Validate source paths ---
|
||||
$DeployPath = Join-Path $CachePath "Deploy"
|
||||
$ToolsPath = Join-Path (Split-Path $CachePath -Parent) "Tools"
|
||||
# Tools is a sibling of Cache in the MCL directory structure
|
||||
if (-not (Test-Path $ToolsPath -PathType Container)) {
|
||||
# Fallback: try Tools inside CachePath parent's parent
|
||||
$ToolsPath = Join-Path (Split-Path (Split-Path $CachePath -Parent) -Parent) "Tools"
|
||||
}
|
||||
if (-not (Test-Path $ToolsPath -PathType Container)) {
|
||||
$ToolsPath = "C:\ProgramData\GEAerospace\MediaCreator\Tools"
|
||||
}
|
||||
$SourcesZip = Join-Path $CachePath "Boot\Sources.zip"
|
||||
|
||||
if (-not (Test-Path $DeployPath -PathType Container)) {
|
||||
Write-Host "ERROR: Deploy directory not found at $DeployPath" -ForegroundColor Red
|
||||
Write-Host " Provide the correct cache path: .\Upload-Image.ps1 -CachePath ""D:\Path\To\Cache""" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host " Cache Path: $CachePath"
|
||||
Write-Host " Deploy: $DeployPath" -ForegroundColor $(if (Test-Path $DeployPath) { "Green" } else { "Red" })
|
||||
Write-Host " Tools: $ToolsPath" -ForegroundColor $(if (Test-Path $ToolsPath) { "Green" } else { "Yellow" })
|
||||
Write-Host " Sources.zip: $SourcesZip" -ForegroundColor $(if (Test-Path $SourcesZip) { "Green" } else { "Yellow" })
|
||||
Write-Host " Server: $Server"
|
||||
if (-not $IncludeDell10) {
|
||||
Write-Host " Excluding: Dell_10 drivers (use -IncludeDell10 to include)" -ForegroundColor Gray
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# --- Connect to SMB share ---
|
||||
Write-Host "Connecting to $Share ..." -ForegroundColor Gray
|
||||
|
||||
# Remove any stale connection
|
||||
net use $Share /delete 2>$null | Out-Null
|
||||
|
||||
$netResult = net use $Share /user:$User $Pass 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "ERROR: Could not connect to $Share" -ForegroundColor Red
|
||||
Write-Host $netResult -ForegroundColor Red
|
||||
Write-Host ""
|
||||
Write-Host "Make sure:" -ForegroundColor Yellow
|
||||
Write-Host " - The PXE server is running at $Server" -ForegroundColor Yellow
|
||||
Write-Host " - This PC is on the 10.9.100.x network" -ForegroundColor Yellow
|
||||
Write-Host " - Samba is running on the PXE server" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
Write-Host "Connected." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
$failed = $false
|
||||
|
||||
# --- Step 1: Copy Deploy/ ---
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "[1/3] Copying Deploy/ ..." -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
|
||||
$robocopyArgs = @($DeployPath, "$Share\Deploy", "/E", "/R:3", "/W:5", "/NP", "/ETA")
|
||||
if (-not $IncludeDell10) {
|
||||
$robocopyArgs += @("/XD", "Dell_10")
|
||||
}
|
||||
& robocopy @robocopyArgs
|
||||
if ($LASTEXITCODE -ge 8) {
|
||||
Write-Host "ERROR: Deploy copy failed (exit code $LASTEXITCODE)" -ForegroundColor Red
|
||||
$failed = $true
|
||||
}
|
||||
|
||||
# --- Step 2: Copy Tools/ ---
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "[2/3] Copying Tools/ ..." -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
|
||||
if (Test-Path $ToolsPath -PathType Container) {
|
||||
robocopy $ToolsPath "$Share\Tools" /E /R:3 /W:5 /NP /ETA
|
||||
if ($LASTEXITCODE -ge 8) {
|
||||
Write-Host "ERROR: Tools copy failed (exit code $LASTEXITCODE)" -ForegroundColor Red
|
||||
$failed = $true
|
||||
}
|
||||
} else {
|
||||
Write-Host "SKIPPED: Tools directory not found at $ToolsPath" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# --- Step 3: Extract and copy Sources/ ---
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "[3/3] Extracting and copying Sources/ ..." -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
|
||||
if (Test-Path $SourcesZip) {
|
||||
$TempExtract = Join-Path $env:TEMP "SourcesExtract"
|
||||
Write-Host " Extracting Sources.zip..."
|
||||
Remove-Item -Recurse -Force $TempExtract -ErrorAction SilentlyContinue
|
||||
Expand-Archive $SourcesZip -DestinationPath $TempExtract -Force
|
||||
|
||||
# Handle nested Sources folder (zip may contain Sources/ at root)
|
||||
$TempSources = $TempExtract
|
||||
if ((Test-Path (Join-Path $TempExtract "Sources")) -and -not (Test-Path (Join-Path $TempExtract "Diskpart"))) {
|
||||
$TempSources = Join-Path $TempExtract "Sources"
|
||||
}
|
||||
|
||||
robocopy $TempSources "$Share\Sources" /E /R:3 /W:5 /NP /ETA
|
||||
if ($LASTEXITCODE -ge 8) {
|
||||
Write-Host "ERROR: Sources copy failed (exit code $LASTEXITCODE)" -ForegroundColor Red
|
||||
$failed = $true
|
||||
}
|
||||
|
||||
# Clean up temp extraction
|
||||
Remove-Item -Recurse -Force $TempExtract -ErrorAction SilentlyContinue
|
||||
} else {
|
||||
Write-Host "SKIPPED: Sources.zip not found at $SourcesZip" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# --- Disconnect ---
|
||||
net use $Share /delete 2>$null | Out-Null
|
||||
|
||||
# --- Summary ---
|
||||
Write-Host ""
|
||||
if ($failed) {
|
||||
Write-Host "========================================" -ForegroundColor Red
|
||||
Write-Host " Upload completed with errors." -ForegroundColor Red
|
||||
Write-Host "========================================" -ForegroundColor Red
|
||||
} else {
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host " Upload complete!" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "Next steps:" -ForegroundColor Cyan
|
||||
Write-Host " 1. Open the PXE webapp: http://$Server`:9009" -ForegroundColor White
|
||||
Write-Host " 2. Go to Image Import" -ForegroundColor White
|
||||
Write-Host " 3. Select source 'image-upload' and target image type" -ForegroundColor White
|
||||
Write-Host " 4. Click Import" -ForegroundColor White
|
||||
Write-Host ""
|
||||
Reference in New Issue
Block a user