dgb-wallet/ops/blockbook-upstream.ps1

18 lines
1 KiB
PowerShell

# Point the live digibyte.x vhost's /blockbook/ proxy at a Blockbook
# upstream (PowerShell entry point; same job as blockbook-upstream.sh).
#
# ops/blockbook-upstream.ps1 atomic # Atomic Wallet's public Blockbook (no key)
# ops/blockbook-upstream.ps1 nownodes # NOWNodes, key from /etc/dgb-core/nownodes.env on the VPS
#
# Pipes blockbook-upstream.remote.sh through `ssh silentmode`; the
# previous vhost is kept under /etc/angie/stale-baks/.
param([Parameter(Mandatory = $true)][ValidateSet('atomic', 'nownodes')][string]$Target)
$ErrorActionPreference = 'Stop'
switch ($Target) {
'atomic' { $upstream = 'digibyte.atomicwallet.io'; $keyhdr = 0 }
'nownodes' { $upstream = 'dgbbook.nownodes.io'; $keyhdr = 1 }
}
$remote = Join-Path $PSScriptRoot 'blockbook-upstream.remote.sh'
# -Raw keeps the script one string; ssh's stdin gets LF line endings.
((Get-Content -Raw $remote) -replace "`r`n", "`n") | ssh silentmode "HOST=$upstream KEYHDR=$keyhdr bash -s"
if ($LASTEXITCODE -ne 0) { throw "remote script failed (exit $LASTEXITCODE)" }