squeaknode/docker/btcd/start-btcctl.sh
Jonathan Zernik 3d8a77cdaa
Run in main docker (#113)
* Docker-compose in main docker folder working

* Fix rpc host in start lnd script

* Remove link alias for btcd in btcctl

* Remove docker-compose links alias for btcd in lnd container

* Remove unused open ports in itest docker-compose

* Remove unused environment variabls from itest docker-compose

* Fix port conflicts between itest and docker docker foler docker-compose containers
2020-07-21 20:48:52 -07:00

60 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# exit from script if error was raised.
set -e
# error function is used within a bash function in order to send the error
# message directly to the stderr output and exit.
error() {
echo "$1" > /dev/stderr
exit 0
}
# return is used within bash function in order to return the value.
return() {
echo "$1"
}
# set_default function gives the ability to move the setting of default
# env variable from docker file to the script thereby giving the ability to the
# user override it durin container start.
set_default() {
# docker initialized env variables with blank string and we can't just
# use -z flag as usually.
BLANK_STRING='""'
VARIABLE="$1"
DEFAULT="$2"
if [[ -z "$VARIABLE" || "$VARIABLE" == "$BLANK_STRING" ]]; then
if [ -z "$DEFAULT" ]; then
error "You should specify default variable"
else
VARIABLE="$DEFAULT"
fi
fi
return "$VARIABLE"
}
# Set default variables if needed.
RPCHOST=$(set_default "$RPCHOST" "localhost")
RPCUSER=$(set_default "$RPCUSER" "devuser")
RPCPASS=$(set_default "$RPCPASS" "devpass")
NETWORK=$(set_default "$NETWORK" "simnet")
PARAMS=""
if [ "$NETWORK" != "mainnet" ]; then
PARAMS=$(echo --$NETWORK)
fi
PARAMS=$(echo $PARAMS \
"--rpccert=/rpc/rpc.cert" \
"--rpcserver=$RPCHOST" \
"--rpcuser=$RPCUSER" \
"--rpcpass=$RPCPASS"
)
PARAMS="$PARAMS $@"
exec btcctl $PARAMS