37 lines
1.9 KiB
PowerShell
37 lines
1.9 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)
|
|
|
|
function Copy-Up($local, $destDir) {
|
|
Set-SCPItem -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -Path $local -Destination $destDir
|
|
}
|
|
|
|
# 1) 源码
|
|
foreach ($f in @("main.rs","enet.rs","tests.rs","aech.rs","hostdemo.rs","dmxhash.rs")) {
|
|
Copy-Up "C:\Users\tonycao\work\light\enet-validator\src\$f" "~/enet-validator/src/"
|
|
Write-Host "sync src/$f"
|
|
}
|
|
Copy-Up "C:\Users\tonycao\work\light\enet-validator\Cargo.toml" "~/enet-validator/"
|
|
Copy-Up "C:\Users\tonycao\work\light\enet-validator\Cargo.lock" "~/enet-validator/"
|
|
Copy-Up "C:\Users\tonycao\work\light\enet-validator\.gitignore" "~/enet-validator/"
|
|
Write-Host "sync root done"
|
|
|
|
# 2) samples
|
|
$hexes = Get-ChildItem "C:\Users\tonycao\work\light\enet-validator\samples\*.hex"
|
|
foreach ($h in $hexes) {
|
|
Copy-Up $h.FullName "~/enet-validator/samples/"
|
|
}
|
|
Write-Host ("sync samples done: " + $hexes.Count + " files")
|
|
|
|
# 3) git init + commit
|
|
$s = New-SSHSession -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -ConnectionTimeout 15
|
|
$cmds = @'
|
|
cd ~/enet-validator && git init -b master 2>/dev/null; git config user.email "tonycao@local"; git config user.name "tonycao"; git add -A; git commit -m "enet-validator: e:net protocol reverse + host-side emulation (AECH claim / encrypted DMX / RDM discovery, hostdemo)" | tail -2; git remote remove origin 2>/dev/null; git remote add origin http://www.kanghexin.work:3000/tonycao/enet-validator.git; echo ---; git log --oneline 2>/dev/null | head -3; git remote -v
|
|
'@
|
|
$r = Invoke-SSHCommand -SessionId $s.SessionId -Command $cmds -TimeOut 120
|
|
$r.Output
|
|
if ($r.Error) { Write-Host "STDERR:"; $r.Error | Select-Object -First 6 }
|
|
Remove-SSHSession -SessionId $s.SessionId | Out-Null
|