Changeset View
Changeset View
Standalone View
Standalone View
contrib/teamcity/ibd.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
export LC_ALL=C | export LC_ALL=C | ||||
set -euxo pipefail | set -euxo pipefail | ||||
### | ### | ||||
# Initial Block Download script. | # Initial Block Download script. | ||||
# | # | ||||
# Runs a bitcoind process until initial block download is complete. | # Runs a bitcoind process until initial block download is complete. | ||||
# Forwards the exit code from bitcoind onward. | # Forwards the exit code from bitcoind onward. | ||||
### | ### | ||||
MYPID=$$ | MYPID=$$ | ||||
# Setup | # Setup | ||||
DATA_DIR="ibd" | TOPLEVEL=$(git rev-parse --show-toplevel) | ||||
DATA_DIR="${TOPLEVEL}"/ibd | |||||
jasonbcox: any reason to leave the `/ibd` out of the double quotes? DEBUG_LOG is this way, for example. | |||||
mkdir -p "${DATA_DIR}" | mkdir -p "${DATA_DIR}" | ||||
DEBUG_LOG="${DATA_DIR}/debug.log" | DEBUG_LOG="${DATA_DIR}/debug.log" | ||||
touch "${DEBUG_LOG}" | touch "${DEBUG_LOG}" | ||||
chmod +x bitcoind | |||||
: "${BITCOIND_BINARY:=}" | |||||
if [[ -z "${BITCOIND_BINARY}" ]]; then | |||||
BITCOIND_BINARY="${TOPLEVEL}"/build/src/bitcoind | |||||
fi | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsThis entire block can be one line: jasonbcox: This entire block can be one line:
`: "${BITCOIND_BINARY:="${TOPLEVEL}/build/src/bitcoind"}"` | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsNote the double quotes after the :=. This is important incase TOPLEVEL contains spaces. jasonbcox: Note the double quotes after the `:=`. This is important incase TOPLEVEL contains spaces. | |||||
FabienAuthorUnsubmitted Done Inline ActionsIt's OK as the whole assignment is enclosed in double quotes. Fabien: It's OK as the whole assignment is enclosed in double quotes. | |||||
# Launch bitcoind using this script's parameters | # Launch bitcoind using this script's parameters | ||||
./bitcoind "-datadir=${DATA_DIR}" "$@" & | "${BITCOIND_BINARY}" "-datadir=${DATA_DIR}" "$@" & | ||||
BITCOIND_PID=$! | BITCOIND_PID=$! | ||||
cleanup() { | cleanup() { | ||||
# Cleanup background processes spawned by this script. | # Cleanup background processes spawned by this script. | ||||
pkill -P ${MYPID} tail || true | pkill -P ${MYPID} tail || true | ||||
} | } | ||||
trap "cleanup" EXIT | trap "cleanup" EXIT | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
any reason to leave the /ibd out of the double quotes? DEBUG_LOG is this way, for example.