Changeset View
Changeset View
Standalone View
Standalone View
contrib/seeds/test-seeds.sh
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if [ ! -x "${BITCOIND}" ]; then | ||||
echo "${BITCOIND} does not exist or has incorrect permissions." | echo "${BITCOIND} does not exist or has incorrect permissions." | ||||
exit 10 | exit 10 | ||||
fi | fi | ||||
if [ ! -x "${BITCOIN_CLI}" ]; then | if [ ! -x "${BITCOIN_CLI}" ]; then | ||||
echo "${BITCOIN_CLI} does not exist or has incorrect permissions." | echo "${BITCOIN_CLI} does not exist or has incorrect permissions." | ||||
exit 11 | exit 11 | ||||
fi | fi | ||||
BITCOIND="${BITCOIND} -connect=0 ${OPTION_TESTNET} -daemon" | TEMP_DATADIR=$(mktemp -d) | ||||
BITCOIN_CLI="${BITCOIN_CLI} ${OPTION_TESTNET}" | BITCOIND="${BITCOIND} -datadir=${TEMP_DATADIR} ${OPTION_TESTNET} -rpcport=18832 -connect=0 -daemon" | ||||
BITCOIN_CLI="${BITCOIN_CLI} -datadir=${TEMP_DATADIR} ${OPTION_TESTNET} -rpcport=18832" | |||||
>&2 echo "Spinning up bitcoind..." | >&2 echo "Spinning up bitcoind..." | ||||
${BITCOIND} || { | ${BITCOIND} || { | ||||
echo "Error starting bitcoind. Stopping script." | echo "Error starting bitcoind. Stopping script." | ||||
exit 12 | exit 12 | ||||
} | } | ||||
cleanup() { | cleanup() { | ||||
# Cleanup background processes spawned by this script. | # Cleanup background processes spawned by this script. | ||||
>&2 echo "Cleaning up bitcoin daemon..." | >&2 echo "Cleaning up bitcoin daemon..." | ||||
${BITCOIN_CLI} stop | ${BITCOIN_CLI} stop | ||||
rm -rf "${TEMP_DATADIR}" | |||||
} | } | ||||
trap "cleanup" EXIT | trap "cleanup" EXIT | ||||
# Short sleep to make sure the RPC server is available | # Short sleep to make sure the RPC server is available | ||||
sleep 0.1 | sleep 0.1 | ||||
# Wait until bitcoind is fully spun up | # Wait until bitcoind is fully spun up | ||||
WARMUP_TIMEOUT=60 | WARMUP_TIMEOUT=60 | ||||
for _ in $(seq 1 ${WARMUP_TIMEOUT}); do | for _ in $(seq 1 ${WARMUP_TIMEOUT}); do | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |