#!/bin/bash export HOME="/var/lib/bitcoind" # gen random pw for rpc server RANDOMPW=$(openssl rand -hex 10) # if password is specified, overwrite config file if [[ "$BITCOIND_RPCPASSWORD" != "" ]]; then cat < $HOME/bitcoin.conf rpcuser=${BITCOIND_RPCUSER:-rpcuser} rpcpassword=${BITCOIND_RPCPASSWORD:-$RANDOMPW} EOF else # if using randomly generated pw, do not overwrite config # if it already exists if [[ ! -e $HOME/bitcoin.conf ]]; then cat < $HOME/bitcoin.conf rpcuser=${BITCOIND_RPCUSER:-rpcuser} rpcpassword=$RANDOMPW EOF fi fi # SECURITY this puts the rpc password into the container log cat $HOME/bitcoin.conf ARGS="" ARGS+=" -printtoconsole" ARGS+=" -disablewallet" ARGS+=" -datadir=$HOME" ARGS+=" -conf=$HOME/bitcoin.conf" ARGS+=" -rpcallowip=::/0" if [[ ! -d $HOME/blocks ]]; then if [[ -e /var/lib/bootstrap.dat ]]; then ARGS+=" -loadblock=/var/lib/bootstrap.dat" fi fi chown -R bitcoind:bitcoind $HOME exec chpst -ubitcoind \ bitcoind $ARGS \ $BITCOIND_EXTRA_OPTS \ 2>&1