53 lines
2.2 KiB
PowerShell
53 lines
2.2 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) docs
|
|
Invoke-Command -ScriptBlock { } | Out-Null
|
|
$s0 = New-SSHSession -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -ConnectionTimeout 15
|
|
Invoke-SSHCommand -SessionId $s0.SessionId -Command "mkdir -p ~/enet-validator/docs ~/enet-validator/scripts/session ~/enet-validator/tools" | Out-Null
|
|
Remove-SSHSession -SessionId $s0.SessionId | Out-Null
|
|
|
|
Copy-Up "C:\Users\tonycao\work\light\enet_protocol.md" "~/enet-validator/docs/"
|
|
Copy-Up "C:\Users\tonycao\work\light\rust_verification_plan.md" "~/enet-validator/docs/"
|
|
Write-Host "sync docs"
|
|
|
|
# 2) scripts (root)
|
|
foreach ($f in @("enet_lib.ps1","Verify-EnetProtocol.ps1","Verify-Rdm.ps1")) {
|
|
Copy-Up "C:\Users\tonycao\work\light\$f" "~/enet-validator/scripts/"
|
|
}
|
|
Write-Host "sync root scripts"
|
|
|
|
# 3) scripts/session (全部 75 个会话脚本)
|
|
$sess = Get-ChildItem "$env:TEMP\opencode\*.ps1"
|
|
foreach ($f in $sess) {
|
|
Copy-Up $f.FullName "~/enet-validator/scripts/session/"
|
|
}
|
|
Write-Host ("sync session scripts: " + $sess.Count)
|
|
|
|
# 4) tools (.cs)
|
|
foreach ($f in @("IlDump.cs","GetTable.cs","Scan.cs")) {
|
|
Copy-Up "$env:TEMP\opencode\$f" "~/enet-validator/tools/"
|
|
}
|
|
Write-Host "sync tools"
|
|
|
|
# 5) README
|
|
Copy-Up "C:\Users\tonycao\work\light\enet-validator\README.md" "~/enet-validator/"
|
|
Write-Host "sync README"
|
|
|
|
# 6) commit + push
|
|
$s = New-SSHSession -ComputerName 192.168.58.7 -Credential $cred -AcceptKey -ConnectionTimeout 15
|
|
$cmds = @'
|
|
cd ~/enet-validator && git add -A && git commit -m "docs+scripts: enet_protocol.md, verification plan, PS verify suite, session analysis scripts, DLL tools, README" | tail -2; git push origin master 2>&1 | tail -3; echo ---; git log --oneline | head -3
|
|
'@
|
|
$r = Invoke-SSHCommand -SessionId $s.SessionId -Command $cmds -TimeOut 180
|
|
$r.Output
|
|
if ($r.Error) { Write-Host "STDERR:"; $r.Error | Select-Object -First 6 }
|
|
Remove-SSHSession -SessionId $s.SessionId | Out-Null
|