43 lines
2.1 KiB
PowerShell
43 lines
2.1 KiB
PowerShell
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
|
$ErrorActionPreference = "Stop"
|
|
Import-Module Posh-SSH
|
|
$sec = ConvertTo-SecureString "0" -AsPlainText -Force
|
|
$cred = New-Object PSCredential("tonycao", $sec)
|
|
$s = New-SSHSession -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -ConnectionTimeout 15
|
|
if (-not $s) { throw "SSH connect failed" }
|
|
$sid = $s.SessionId
|
|
|
|
# 1) 同步源码
|
|
$srcFiles = @("main.rs","enet.rs","tests.rs","aech.rs","hostdemo.rs","dmxhash.rs")
|
|
foreach ($f in $srcFiles) {
|
|
Set-SCPItem -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -Path "C:\Users\tonycao\work\light\enet-validator\src\$f" -Destination "~/enet-validator/src/"
|
|
}
|
|
Set-SCPItem -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -Path "C:\Users\tonycao\work\light\enet-validator\Cargo.toml" -Destination "~/enet-validator/"
|
|
Set-SCPItem -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -Path "C:\Users\tonycao\work\light\enet-validator\Cargo.lock" -Destination "~/enet-validator/"
|
|
Set-SCPItem -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -Path "C:\Users\tonycao\work\light\enet-validator\.gitignore" -Destination "~/enet-validator/"
|
|
|
|
# 2) 同步 samples
|
|
Invoke-SSHCommand -SessionId $sid -Command "mkdir -p ~/enet-validator/samples" | Out-Null
|
|
Get-ChildItem "C:\Users\tonycao\work\light\enet-validator\samples\*.hex" | ForEach-Object {
|
|
Set-SCPItem -SessionId $sid -Path $_.FullName -Destination "~/enet-validator/samples/"
|
|
}
|
|
Write-Host "sync done"
|
|
|
|
# 3) git init + commit + push
|
|
$cmds = @"
|
|
cd ~/enet-validator
|
|
git init -b master 2>/dev/null || true
|
|
git config user.email "tonycao@local" || true
|
|
git config user.name "tonycao" || true
|
|
git add -A
|
|
git commit -m "enet-validator: e:net protocol reverse + host-side emulation (AECH/DMX/RDM, hostdemo)" || true
|
|
git remote remove origin 2>/dev/null || true
|
|
git remote add origin http://www.kanghexin.work:3000/tonycao/enet-validator.git
|
|
git log --oneline | head -3
|
|
git remote -v
|
|
"@
|
|
$r = Invoke-SSHCommand -SessionId $sid -Command $cmds -TimeOut 60
|
|
$r.Output
|
|
if ($r.Error) { $r.Error | Select-Object -First 5 }
|
|
Remove-SSHSession -SessionId $sid | Out-Null
|