Files
buryan-infra/ops/combine/research-pack/sync-to-host.ps1
T
2026-11-18 20:40:18 +03:00

34 lines
2.1 KiB
PowerShell

param()
$ErrorActionPreference = "Continue"
$base = "D:\Buryans Hub\sources\plan\research-pack"
$hostIp = "192.168.1.10"
$log = Join-Path $base "sync-to-host.log"
function Log($m) { Add-Content -Path $log -Value "$(Get-Date -Format s) $m" }
if (-not (Test-NetConnection $hostIp -Port 22 -InformationLevel Quiet -WarningAction SilentlyContinue)) {
Log "host unreachable"
exit 1
}
Log "host reachable, copying"
$remote = "/tmp/prism-import"
try {
ssh -o BatchMode=yes -o StrictHostKeyChecking=no root@$hostIp "mkdir -p $remote" | Out-Null
if ($LASTEXITCODE -ne 0) { throw "remote mkdir failed" }
scp -o BatchMode=yes -o StrictHostKeyChecking=no -r (Join-Path $base "pc-results-merged-clean") "root@${hostIp}:$remote/" | Out-Null
if ($LASTEXITCODE -ne 0) { throw "copy clean failed" }
if (Test-Path (Join-Path $base "pc-results-night")) {
scp -o BatchMode=yes -o StrictHostKeyChecking=no -r (Join-Path $base "pc-results-night") "root@${hostIp}:$remote/" | Out-Null
if ($LASTEXITCODE -ne 0) { throw "copy night failed" }
}
scp -o BatchMode=yes -o StrictHostKeyChecking=no (Join-Path $base "yealink-current-staging.yaml") "root@${hostIp}:$remote/" | Out-Null
if ($LASTEXITCODE -ne 0) { throw "copy yealink yaml failed" }
scp -o BatchMode=yes -o StrictHostKeyChecking=no (Join-Path $base "other-vendors-staging.yaml") "root@${hostIp}:$remote/" | Out-Null
if ($LASTEXITCODE -ne 0) { throw "copy other yaml failed" }
ssh -o BatchMode=yes -o StrictHostKeyChecking=no root@$hostIp "cd /root/buryan-infra; mkdir -p ops/combine/staging/ingest-pc-clean; cp $remote/yealink-current-staging.yaml $remote/other-vendors-staging.yaml ops/combine/staging/ingest-pc-clean/; if [ -d $remote/pc-results-night ]; then rm -rf ops/combine/staging/raw-night; cp -r $remote/pc-results-night ops/combine/staging/raw-night; fi; /opt/work-hub/venv/bin/python ops/combine/research-pack/ingest_extracted.py --in $remote/pc-results-merged-clean --out ops/combine/staging/ingest-pc-clean >> /tmp/prism-sync.log 2>&1; echo done" | Out-Null
if ($LASTEXITCODE -ne 0) { throw "remote ingest failed" }
Log "ingested"
exit 0
} catch {
Log "sync failed: $($_.Exception.Message)"
exit 1
}