Files
ProjectOctopus/agent-wdd/one-build-and-run.ps1
2025-02-27 17:19:36 +08:00

28 lines
1.1 KiB
PowerShell

try {
$ErrorActionPreference = "Stop"
Write-Host "1. Building binary exec file..." -ForegroundColor Cyan
& "C:\Users\wdd\go\bin\gox.exe" -osarch="linux/amd64" -output "build/agent-wdd_{{.OS}}_{{.Arch}}"
# 执行远程ssh命令 ssh root@192.168.35.71 "rm /root/agent-wdd_linux_amd64"
Write-Host "2. Cleaning old binary file..." -ForegroundColor Yellow
ssh root@192.168.35.71 "rm -f /root/agent-wdd_linux_amd64 && rm /usr/local/etc/wdd/agent-wdd-config.yaml"
Write-Host "3. Uploading binary exec..." -ForegroundColor Green
scp build/agent-wdd_linux_amd64 root@192.168.35.71:/root/
Write-Host "4. Exec the command ..." -ForegroundColor Blue
Write-Host ""
Write-Host ""
ssh root@192.168.35.71 "chmod +x agent-wdd_linux_amd64 && ./agent-wdd_linux_amd64 download http://192.168.35.70:9000/ping/ 123.txt"
Write-Host ""
Write-Host ""
# Write-Host "5. Cheak Info Result ..." -ForegroundColor Blue
# ssh root@192.168.35.71 "cat /usr/local/etc/wdd/agent-wdd-config.yaml"
} catch {
Write-Host "操作失败: $_" -ForegroundColor Red
exit 1
}