32 lines
673 B
Bash
32 lines
673 B
Bash
#!/bin/bash
|
|
|
|
export HOME="/var/lib/bitcoin"
|
|
|
|
# gen random pw for rpc server
|
|
RANDOMPW=$(dd if=/dev/urandom bs=10 count=1 status=none | shasum | cut -b 1-20)
|
|
|
|
cat <<EOF > $HOME/bitcoin.conf
|
|
rpcuser=${BITCOIND_RPCUSER:-rpcuser}
|
|
rpcpassword=${BITCOIND_RPCPASSWORD:-$RANDOMPW}
|
|
EOF
|
|
|
|
ARGS=""
|
|
ARGS+=" -printtoconsole"
|
|
ARGS+=" -disablewallet"
|
|
ARGS+=" -datadir=$HOME"
|
|
ARGS+=" -conf=$HOME/bitcoin.conf"
|
|
ARGS+=" -rpcallowip=::/0"
|
|
|
|
if [[ ! -d $HOME/blocks ]]; then
|
|
if [[ -e $HOME/bootstrap.dat ]]; then
|
|
ARGS+=" -loadblock=$HOME/bootstrap.dat"
|
|
fi
|
|
fi
|
|
|
|
chown -R bitcoin:bitcoin $HOME
|
|
|
|
exec chpst -ubitcoin \
|
|
bitcoind $ARGS \
|
|
$BITCOIND_EXTRA_OPTS \
|
|
2>&1
|