37 lines
763 B
Bash
37 lines
763 B
Bash
#!/bin/bash
|
|
|
|
export HOME="/var/lib/bitcoind"
|
|
|
|
# gen random pw for rpc server
|
|
RANDOMPW=$(openssl rand -hex 10)
|
|
|
|
if [[ ! -e $HOME/bitcoin.conf ]]; then
|
|
cat <<EOF > $HOME/bitcoin.conf
|
|
rpcuser=${BITCOIND_RPCUSER:-rpcuser}
|
|
rpcpassword=${BITCOIND_RPCPASSWORD:-$RANDOMPW}
|
|
EOF
|
|
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
|