enet-validator/scripts/session/start_local.ps1

24 lines
835 B
PowerShell
Raw Permalink Normal View History

[Console]::OutputEncoding = [Text.Encoding]::UTF8
Set-ExecutionPolicy -Scope Process Bypass -Force
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
$cmd = @'
cat > ~/run_butler_local.sh << 'EOF'
#!/bin/bash
pkill -f "release/enet-validator" 2>/dev/null
sleep 1
cd /home/tonycao/enet-validator
nohup ./target/release/enet-validator device 192.168.58.7 00161cf12e88 86400 > /home/tonycao/butler.log 2>&1 &
disown
sleep 4
echo "PID=$(pgrep -f 'release/enet-validator' | head -1)"
EOF
chmod +x ~/run_butler_local.sh
bash ~/run_butler_local.sh
'@
$r = Invoke-SSHCommand -SSHSession $s -Command $cmd
Write-Host ($r.Output -join "`n")
Remove-SSHSession $s | Out-Null