lnd.xprv/docker/lnd/start-lnd.sh
afederigo 2a602b6d61 docker: update docker instructions to be aware of multi-chain config
This commit contains replacement of previous --rpccert flag on newest
--bitcoin.rpccert flag in docker lnd config.
2017-05-11 14:42:27 -07:00

58 lines
1.4 KiB
Bash
Executable File

#!/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
# mesage 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.
RPCUSER=$(set_default "$RPCUSER" "devuser")
RPCPASS=$(set_default "$RPCPASS" "devpass")
DEBUG=$(set_default "$DEBUG" "debug")
BITCOIN_NETWORK=$(set_default "$BITCOIN_NETWORK" "simnet")
lnd \
--datadir="/data" \
--logdir="/data" \
--bitcoin.active \
"--bitcoin.$BITCOIN_NETWORK" \
--bitcoin.rpchost="btcd" \
--bitcoin.rpccert="/rpc/rpc.cert" \
--bitcoin.rpcuser="$RPCUSER" \
--bitcoin.rpcpass="$RPCPASS" \
--debuglevel="$DEBUG" \
"$@"