From 5e4b7d0b034644c175441967da535e8bcd0cda98 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Thu, 14 Jun 2018 12:42:36 +0200 Subject: [PATCH] Added helper scrip to make tunnels from localhost to dev server --- contrib/scripts/start-backend-tunnels.sh | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 contrib/scripts/start-backend-tunnels.sh diff --git a/contrib/scripts/start-backend-tunnels.sh b/contrib/scripts/start-backend-tunnels.sh new file mode 100755 index 00000000..913a8e81 --- /dev/null +++ b/contrib/scripts/start-backend-tunnels.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage: $(basename $0) host" 1>&2 + exit 1 +fi + +host=$1 + +# change dir to root of git repository +cd $(cd $(dirname $(readlink -f $0)) && git rev-parse --show-toplevel) + +# get all testnet ports from configs/ +testnet_ports=$(gawk 'match($0, /"rpcURL":\s+"(http|ws):\/\/[^:]+:([0-9]+)"/, a) {print a[2]}' configs/*_testnet*.json) + +for port in $testnet_ports +do + ssh -nNT -L $port:localhost:$port blockbook-dev.corp & + pid=$! + echo "Started tunnel to ${host}:${port} (pid: ${pid})" +done + +at_exit() { + pkill -P $$ +} + +trap at_exit EXIT +sleep inf