Introduce devtoprod:release orchestrator, config file, CLI result footers on deploy scripts, auto-thumb regeneration on curator fixes, and updated deploy documentation. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
2.1 KiB
PowerShell
60 lines
2.1 KiB
PowerShell
# Sync dev image files to TrueNAS production volume.
|
|
#
|
|
# Usage (from repo root):
|
|
# npm run devtoprod:images
|
|
# Copies data/images/ → \\192.168.10.122\Gallery\data\images
|
|
# Map the share first if needed: net use \\192.168.10.122\Gallery /user:YOUR_TRUENAS_USER
|
|
|
|
param(
|
|
[string]$Source = (Join-Path $PSScriptRoot "..\..\data\images"),
|
|
[string]$Dest = "\\192.168.10.122\Gallery\data\images",
|
|
[switch]$SkipConfirm
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
. (Join-Path $PSScriptRoot "lib\Deploy-CliResult.ps1")
|
|
|
|
$Source = (Resolve-Path $Source -ErrorAction Stop).Path
|
|
|
|
Write-Host "Source: $Source"
|
|
Write-Host "Dest: $Dest"
|
|
|
|
if (-not $SkipConfirm) {
|
|
$confirm = Read-Host "Copy all files (skip older)? Type yes"
|
|
if ($confirm -ne "yes") {
|
|
Write-DeployCliResult -Script 'sync-images-to-prod' -Success $false -Summary 'Image sync aborted by user.'
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
$smbRoot = "\\192.168.10.122\Gallery"
|
|
if ($env:SMB_USER -and $env:SMB_PASSWORD) {
|
|
Write-Host "Mapping $smbRoot ..."
|
|
net use $smbRoot /user:$env:SMB_USER $env:SMB_PASSWORD 2>&1 | Out-Host
|
|
} elseif (-not (Test-Path $smbRoot)) {
|
|
Write-Warning "Cannot access $smbRoot (not authenticated)."
|
|
Write-Warning "Map the share first, e.g.:"
|
|
Write-Warning (' net use ' + $smbRoot + ' /user:YOUR_TRUENAS_USER')
|
|
Write-Warning 'or set $env:SMB_USER and $env:SMB_PASSWORD before running this script.'
|
|
Write-DeployCliResult -Script 'sync-images-to-prod' -Success $false -Summary 'SMB share not reachable - aborting before robocopy.'
|
|
exit 1
|
|
}
|
|
|
|
try {
|
|
if (-not (Test-Path $Dest)) {
|
|
New-Item -ItemType Directory -Path $Dest -Force | Out-Null
|
|
}
|
|
} catch {
|
|
Write-Host "Note: could not pre-create dest (will rely on robocopy): $($_.Exception.Message)"
|
|
}
|
|
|
|
robocopy $Source $Dest /E /XO /R:2 /W:3 /NFL /NDL /NJH /NJS
|
|
$code = $LASTEXITCODE
|
|
if ($code -ge 8) {
|
|
Write-DeployCliResult -Script 'sync-images-to-prod' -Success $false -Summary "robocopy failed with exit code $code"
|
|
exit $code
|
|
}
|
|
|
|
Write-DeployCliResult -Script 'sync-images-to-prod' -Success $true -Summary 'Image sync complete.' -Details @("robocopy exit code: $code", "Dest: $Dest")
|
|
exit 0
|