github.com/decred/dcrlnd@v0.7.6/docker/dcrlnd/start-dcrlnd.sh (about) 1 #!/usr/bin/env bash 2 3 # exit from script if error was raised. 4 set -e 5 6 # error function is used within a bash function in order to send the error 7 # message directly to the stderr output and exit. 8 error() { 9 echo "$1" > /dev/stderr 10 exit 0 11 } 12 13 # return is used within bash function in order to return the value. 14 return() { 15 echo "$1" 16 } 17 18 # set_default function gives the ability to move the setting of default 19 # env variable from docker file to the script thereby giving the ability to the 20 # user override it during container start. 21 set_default() { 22 # docker initialized env variables with blank string and we can't just 23 # use -z flag as usually. 24 BLANK_STRING='""' 25 26 VARIABLE="$1" 27 DEFAULT="$2" 28 29 if [[ -z "$VARIABLE" || "$VARIABLE" == "$BLANK_STRING" ]]; then 30 31 if [ -z "$DEFAULT" ]; then 32 error "You should specify default variable" 33 else 34 VARIABLE="$DEFAULT" 35 fi 36 fi 37 38 return "$VARIABLE" 39 } 40 41 # Set default variables if needed. 42 RPCUSER=$(set_default "$RPCUSER" "devuser") 43 RPCPASS=$(set_default "$RPCPASS" "devpass") 44 DEBUG=$(set_default "$DEBUG" "debug") 45 NETWORK=$(set_default "$NETWORK" "simnet") 46 BACKEND="dcrd" 47 48 PARAMS="" 49 if [ "$NETWORK" != "mainnet" ]; then 50 PARAMS=$(echo --$NETWORK) 51 fi 52 53 # CAUTION: DO NOT use the --noseedback for production/mainnet setups, ever! 54 # Also, setting --rpclisten to 0.0.0.0 will cause it to listen on an IP 55 # address that is reachable on the internal network. If you do this outside of 56 # docker, this might be a security concern! 57 58 PARAMS=$(echo $PARAMS \ 59 --noseedbackup \ 60 --logdir=/data \ 61 --node=dcrd \ 62 "--$BACKEND.rpccert"="/rpc/rpc.cert" \ 63 "--$BACKEND.rpchost"="dcrd" \ 64 "--$BACKEND.rpcuser"="$RPCUSER" \ 65 "--$BACKEND.rpcpass"="$RPCPASS" \ 66 --rpclisten=0.0.0.0 \ 67 "--rpclisten=localhost:10009" \ 68 --restlisten=0.0.0.0 \ 69 --listen=0.0.0.0 \ 70 --debuglevel="$DEBUG" \ 71 "$@" 72 ) 73 74 echo "Run dcrlnd $PARAMS" 75 exec dcrlnd $PARAMS