兼容生产服务器旧版 SCP 上传

This commit is contained in:
chenxi 2026-09-28 10:40:36 +08:00
parent e23fc595d6
commit 1c35d088df

View File

@ -30,6 +30,7 @@ $repoRoot = (Resolve-Path (Join-Path $scriptRoot '..')).Path
. (Join-Path $scriptRoot 'deploy-auth.ps1')
$authSession = $null
$sshOptions = @()
$scpOptions = if ($IsMacOS) { @('-O') } else { @() }
$sshTarget = "${SshUser}@${Server}"
$imageName = 'caiwu_akaunting'
$targetPlatform = 'linux/amd64'
@ -434,7 +435,7 @@ try {
if ($BootstrapServer) {
$bootstrapRemote = "/tmp/caiwu-bootstrap-$imageTag.sh"
Invoke-Native {
scp @sshOptions deploy/bootstrap-server.sh "${sshTarget}:$bootstrapRemote"
scp @scpOptions @sshOptions deploy/bootstrap-server.sh "${sshTarget}:$bootstrapRemote"
} '上传服务器初始化脚本失败。'
Invoke-Native {
ssh @sshOptions $sshTarget "chmod 700 '$bootstrapRemote' && '$bootstrapRemote' '$AppUrl' '$RemotePath' && rm -f '$bootstrapRemote'"
@ -449,7 +450,7 @@ try {
$migrationFlag = if ($AllowMigrations) { '1' } else { '0' }
Invoke-Native {
scp @sshOptions `
scp @scpOptions @sshOptions `
compose.jiangling.yml `
deploy/activate-release.sh `
deploy/activate-incremental-release.sh `
@ -483,7 +484,7 @@ try {
Remove-Item -LiteralPath $localTar -Force
$archiveSizeMB = [math]::Round((Get-Item -LiteralPath $localArchive).Length / 1MB, 1)
Write-Host "首次初始化全量包:$archiveSizeMB MiB"
Invoke-Native { scp @sshOptions $localArchive "${sshTarget}:$remoteArchive" } '上传镜像失败。'
Invoke-Native { scp @scpOptions @sshOptions $localArchive "${sshTarget}:$remoteArchive" } '上传镜像失败。'
Invoke-Native {
ssh @sshOptions $sshTarget "chmod 700 '$RemotePath/'*.sh && chmod 644 '$RemotePath/config-db-init.sh' && '$RemotePath/activate-release.sh' '$remoteArchive' '$imageTag' '$RemotePath' '$deploySha' '$migrationFlag' '$KeepImages' && '$RemotePath/setup-incremental-registry.sh' '$RemotePath' '$RemotePath/registry-config.yml'"
} '服务器激活、健康检查或增量仓库初始化失败。'