2017-01-12 03:12:32 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-01-13 23:23:30 +03:00
|
|
|
# exit from script if error was raised.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# error function is used within a bash function in order to send the error
|
2018-02-07 06:11:11 +03:00
|
|
|
# message directly to the stderr output and exit.
|
2017-01-13 23:23:30 +03:00
|
|
|
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
|
2019-09-04 12:15:36 +03:00
|
|
|
# user override it during container start.
|
2017-01-13 23:23:30 +03:00
|
|
|
set_default() {
|
2017-01-12 03:12:32 +03:00
|
|
|
# docker initialized env variables with blank string and we can't just
|
|
|
|
# use -z flag as usually.
|
|
|
|
BLANK_STRING='""'
|
|
|
|
|
|
|
|
VARIABLE="$1"
|
2017-01-13 23:23:30 +03:00
|
|
|
DEFAULT="$2"
|
2017-01-12 03:12:32 +03:00
|
|
|
|
|
|
|
if [[ -z "$VARIABLE" || "$VARIABLE" == "$BLANK_STRING" ]]; then
|
|
|
|
|
|
|
|
if [ -z "$DEFAULT" ]; then
|
2017-01-13 23:23:30 +03:00
|
|
|
error "You should specify default variable"
|
2017-01-12 03:12:32 +03:00
|
|
|
else
|
|
|
|
VARIABLE="$DEFAULT"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-01-13 23:23:30 +03:00
|
|
|
return "$VARIABLE"
|
2017-01-12 03:12:32 +03:00
|
|
|
}
|
|
|
|
|
2017-01-13 23:23:30 +03:00
|
|
|
# Set default variables if needed.
|
|
|
|
RPCUSER=$(set_default "$RPCUSER" "devuser")
|
|
|
|
RPCPASS=$(set_default "$RPCPASS" "devpass")
|
|
|
|
DEBUG=$(set_default "$DEBUG" "debug")
|
2017-05-13 23:21:14 +03:00
|
|
|
NETWORK=$(set_default "$NETWORK" "simnet")
|
2017-05-13 23:22:40 +03:00
|
|
|
CHAIN=$(set_default "$CHAIN" "bitcoin")
|
2018-01-13 08:34:46 +03:00
|
|
|
BACKEND="btcd"
|
2019-09-04 12:15:36 +03:00
|
|
|
HOSTNAME=$(hostname)
|
2018-01-17 04:19:33 +03:00
|
|
|
if [[ "$CHAIN" == "litecoin" ]]; then
|
|
|
|
BACKEND="ltcd"
|
2018-01-13 08:34:46 +03:00
|
|
|
fi
|
2017-01-12 03:12:32 +03:00
|
|
|
|
2019-09-04 12:15:36 +03:00
|
|
|
# CAUTION: DO NOT use the --noseedback for production/mainnet setups, ever!
|
|
|
|
# Also, setting --rpclisten to $HOSTNAME will cause it to listen on an IP
|
|
|
|
# address that is reachable on the internal network. If you do this outside of
|
|
|
|
# docker, this might be a security concern!
|
|
|
|
|
2018-03-21 21:09:29 +03:00
|
|
|
exec lnd \
|
2018-09-05 04:53:59 +03:00
|
|
|
--noseedbackup \
|
2017-05-13 23:22:40 +03:00
|
|
|
"--$CHAIN.active" \
|
|
|
|
"--$CHAIN.$NETWORK" \
|
2018-01-13 08:34:46 +03:00
|
|
|
"--$CHAIN.node"="btcd" \
|
|
|
|
"--$BACKEND.rpccert"="/rpc/rpc.cert" \
|
|
|
|
"--$BACKEND.rpchost"="blockchain" \
|
|
|
|
"--$BACKEND.rpcuser"="$RPCUSER" \
|
|
|
|
"--$BACKEND.rpcpass"="$RPCPASS" \
|
2019-09-04 12:15:36 +03:00
|
|
|
"--rpclisten=$HOSTNAME:10009" \
|
2017-01-12 03:12:32 +03:00
|
|
|
--debuglevel="$DEBUG" \
|
|
|
|
"$@"
|