2016-04-11 03:38:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-08-18 10:51:04 +00:00
|
|
|
export HOME="/var/lib/bitcoind"
|
2016-04-11 03:38:48 +00:00
|
|
|
|
|
|
|
# gen random pw for rpc server
|
2016-04-11 03:43:05 +00:00
|
|
|
RANDOMPW=$(dd if=/dev/urandom bs=10 count=1 status=none | shasum | cut -b 1-20)
|
2016-04-11 03:38:48 +00:00
|
|
|
|
2016-04-11 03:43:05 +00:00
|
|
|
cat <<EOF > $HOME/bitcoin.conf
|
|
|
|
rpcuser=${BITCOIND_RPCUSER:-rpcuser}
|
|
|
|
rpcpassword=${BITCOIND_RPCPASSWORD:-$RANDOMPW}
|
2016-04-11 03:38:48 +00:00
|
|
|
EOF
|
|
|
|
|
2016-08-18 09:45:34 +00:00
|
|
|
# SECURITY this puts the rpc password into the container log
|
|
|
|
cat $HOME/bitcoin.conf
|
|
|
|
|
2016-04-11 15:58:36 +00:00
|
|
|
ARGS=""
|
|
|
|
ARGS+=" -printtoconsole"
|
|
|
|
ARGS+=" -disablewallet"
|
|
|
|
ARGS+=" -datadir=$HOME"
|
|
|
|
ARGS+=" -conf=$HOME/bitcoin.conf"
|
|
|
|
ARGS+=" -rpcallowip=::/0"
|
|
|
|
|
|
|
|
if [[ ! -d $HOME/blocks ]]; then
|
2016-04-11 16:00:44 +00:00
|
|
|
if [[ -e /var/lib/bootstrap.dat ]]; then
|
|
|
|
ARGS+=" -loadblock=/var/lib/bootstrap.dat"
|
2016-04-11 15:58:36 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-08-18 10:51:04 +00:00
|
|
|
chown -R bitcoind:bitcoind $HOME
|
2016-04-11 03:43:05 +00:00
|
|
|
|
2016-08-18 10:51:04 +00:00
|
|
|
exec chpst -ubitcoind \
|
2016-04-11 15:58:36 +00:00
|
|
|
bitcoind $ARGS \
|
2016-04-11 03:38:48 +00:00
|
|
|
$BITCOIND_EXTRA_OPTS \
|
|
|
|
2>&1
|