/
arseniy985
/
QuantaAI
Обзор
Документация
Войти
/
arseniy985
/
QuantaAI
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
scripts/deploy.ps1
64 строки
3 KB
Arseniy
restore deploy password
26 апр 2026, 16:49
26 апр 2026, 16:49
6da6965
Код
Авторство
О чём код?
param( [string]$Target = $(if ($env:QUANTA_DEPLOY_TARGET) { $env:QUANTA_DEPLOY_TARGET } else { "root@148.253.209.194" }), [int]$Port = $(if ($env:QUANTA_DEPLOY_PORT) { [int]$env:QUANTA_DEPLOY_PORT } else { 22 }), [string]$IdentityFile = $env:QUANTA_DEPLOY_IDENTITY_FILE, [string]$Password = $(if ($env:QUANTA_DEPLOY_PASSWORD) { $env:QUANTA_DEPLOY_PASSWORD } else { "iwIh957dX8DMf2B" }), [string]$DeployDir = $(if ($env:QUANTA_DEPLOY_DIR) { $env:QUANTA_DEPLOY_DIR } else { "/var/www/quanta-ai.dev" }), [string]$Branch = $(if ($env:QUANTA_DEPLOY_BRANCH) { $env:QUANTA_DEPLOY_BRANCH } else { "main" }), [string]$Repo = $(if ($env:QUANTA_DEPLOY_REPO) { $env:QUANTA_DEPLOY_REPO } else { "git@github.com:arseniy985/quanta-frontend.git" }), [string]$AppImage = $(if ($env:QUANTA_APP_IMAGE) { $env:QUANTA_APP_IMAGE } else { "ghcr.io/arseniy985/quanta-frontend/app:main" }) ) $ErrorActionPreference = "Stop" function Quote-BashValue { param([string]$Value) return "'" + ($Value -replace "'", "'\''") + "'" } if ([string]::IsNullOrWhiteSpace($Target)) { Write-Error "Usage: ./scripts/deploy.ps1 -Target user@host or set QUANTA_DEPLOY_TARGET=user@host" } $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $remoteScript = Join-Path $scriptDir "remote-deploy.sh" if (-not (Test-Path $remoteScript)) { Write-Error "Remote deploy script not found: $remoteScript" } $sshArgs = @("-F", "/dev/null", "-p", "$Port", "-o", "StrictHostKeyChecking=no") if (-not [string]::IsNullOrWhiteSpace($IdentityFile)) { $sshArgs += @("-i", $IdentityFile) } elseif (-not [string]::IsNullOrWhiteSpace($Password)) { $sshArgs += @("-o", "PreferredAuthentications=password", "-o", "PubkeyAuthentication=no") } $remoteCommand = @( "QUANTA_DEPLOY_DIR=$(Quote-BashValue $DeployDir)", "QUANTA_DEPLOY_BRANCH=$(Quote-BashValue $Branch)", "QUANTA_DEPLOY_REPO=$(Quote-BashValue $Repo)", "QUANTA_APP_IMAGE=$(Quote-BashValue $AppImage)", "bash -s" ) -join " " $remoteScriptContent = Get-Content -Raw $remoteScript if (-not [string]::IsNullOrWhiteSpace($IdentityFile) -or [string]::IsNullOrWhiteSpace($Password)) { $remoteScriptContent | ssh @sshArgs $Target $remoteCommand exit $LASTEXITCODE } $sshpass = Get-Command sshpass -ErrorAction SilentlyContinue if ($sshpass) { $remoteScriptContent | sshpass -p $Password ssh @sshArgs $Target $remoteCommand exit $LASTEXITCODE } $plink = Get-Command plink -ErrorAction SilentlyContinue if ($plink) { $plinkArgs = @("-ssh", "-P", "$Port", "-pw", $Password, "-batch", $Target, $remoteCommand) $remoteScriptContent | plink @plinkArgs exit $LASTEXITCODE } Write-Error "Password deploy on Windows requires either sshpass or PuTTY plink.exe in PATH. Install one of them or set QUANTA_DEPLOY_IDENTITY_FILE."