$ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" $Node = 10 $HostName = "38.247.185.235" $User = "administrator" $Base = "https://vram.theappmasters.com/files" $Work = Join-Path $env:TEMP ("danonode-" + $Node + "-" + [guid]::NewGuid().ToString("N")) New-Item -ItemType Directory -Force -Path $Work | Out-Null function Get-BootstrapFile($Name) { Invoke-WebRequest -Uri "$Base/$Name" -OutFile (Join-Path $Work $Name) } Get-BootstrapFile "install-node.sh" Get-BootstrapFile "node_agent.py" Get-BootstrapFile "requirements.txt" Get-BootstrapFile "node10.json" if (-not (Get-Command ssh -ErrorAction SilentlyContinue)) { throw "OpenSSH client is required." } if (-not (Get-Command scp -ErrorAction SilentlyContinue)) { throw "OpenSSH scp client is required." } Write-Host "[DanoNode] Connecting to $User@$HostName" -ForegroundColor Cyan ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 "$User@$HostName" "echo DANONODE_SSH_OK" if ($LASTEXITCODE -ne 0) { throw "SSH connection failed." } $Remote="/tmp/danonode-bootstrap-$Node" ssh "$User@$HostName" "rm -rf '$Remote' && mkdir -p '$Remote/agent' '$Remote/manifests'" scp (Join-Path $Work "install-node.sh") "$($User)@$($HostName):$Remote/install-node.sh" scp (Join-Path $Work "node_agent.py") "$($User)@$($HostName):$Remote/agent/node_agent.py" scp (Join-Path $Work "requirements.txt") "$($User)@$($HostName):$Remote/agent/requirements.txt" scp (Join-Path $Work "node10.json") "$($User)@$($HostName):$Remote/manifests/node10.json" Write-Host "[DanoNode] Provisioning DanoNode$Node" -ForegroundColor Cyan ssh -t "$User@$HostName" "chmod +x '$Remote/install-node.sh' && sudo '$Remote/install-node.sh' '$Remote/manifests/node10.json' '$Remote'" if ($LASTEXITCODE -ne 0) { throw "Provisioning failed. Run the same one-line command again to resume." } ssh "$User@$HostName" "curl -fsS http://127.0.0.1:7777/health && echo && curl -fsS http://127.0.0.1:7777/capabilities && echo" Write-Host "DanoNode$Node READY" -ForegroundColor Green Remove-Item -Recurse -Force $Work -ErrorAction SilentlyContinue