# 重试部署脚本 param( [string]$Server = "45.249.208.118", [string]$Username = "root", [string]$Password = "lxvhNYFZ4160", [string]$RemotePath = "/root/deploy" ) $plinkPath = "C:\Program Files\PuTTY\plink.exe" $hostKey = "SHA256:WZOtvC/+IWw29P8vyovSabmIRFkQ/Bnmhj+qhTshA4Q" function Invoke-SSHCommand { param([string]$Command) Write-Host "执行: $Command" -ForegroundColor Gray $result = & $plinkPath -batch -ssh -hostkey $hostKey -pw $Password "${Username}@${Server}" $Command 2>&1 return $LASTEXITCODE } Write-Host "=== 重试部署 ===" -ForegroundColor Cyan # 1. 先手动拉取 minio-init 镜像 Write-Host "正在拉取 minio-init 镜像..." -ForegroundColor Yellow $pullResult = Invoke-SSHCommand "docker pull minio/mc:RELEASE.2025-04-22T22-12-26Z" if ($pullResult -eq 0) { Write-Host "✓ minio-init 镜像拉取成功" -ForegroundColor Green } else { Write-Host "⚠ minio-init 镜像拉取失败,将重试部署" -ForegroundColor Yellow } # 2. 重试部署 Write-Host "`n正在启动容器..." -ForegroundColor Yellow $deployResult = Invoke-SSHCommand "cd ${RemotePath} && docker compose up -d" if ($deployResult -eq 0) { Write-Host "✓ 容器启动成功" -ForegroundColor Green # 等待容器就绪 Write-Host "等待容器就绪..." -ForegroundColor Gray Start-Sleep -Seconds 10 # 检查容器状态 Write-Host "`n容器状态:" -ForegroundColor Cyan Invoke-SSHCommand "cd ${RemotePath} && docker compose ps" Write-Host "`n✓ 部署完成!" -ForegroundColor Green } else { Write-Host "✗ 部署失败,退出码: $deployResult" -ForegroundColor Red exit $deployResult }