diff --git a/bitcoin/exports.sh b/bitcoin/exports.sh index 9acef78..10d2e6f 100644 --- a/bitcoin/exports.sh +++ b/bitcoin/exports.sh @@ -128,20 +128,24 @@ fi { # Migrate settings for app updates differently to fresh installs - BITCOIN_INSTALL_EXISTS="false" BITCOIN_DATA_DIR="${EXPORTS_APP_DIR}/data/bitcoin" - if [[ -d "${BITCOIN_DATA_DIR}/blocks" ]] || [[ -d "${BITCOIN_DATA_DIR}/testnet3/blocks" ]] || [[ -d "${BITCOIN_DATA_DIR}/regtest/blocks" ]] + IS_POST_ADVANCED_SETTINGS_INSTALL_FILE_PATH="${EXPORTS_APP_DIR}/data/app/IS_POST_ADVANCED_SETTINGS_INSTALL" + + # If no blocks directory exists, we write out a file to indicate that this is a fresh install. + # This gets around the issue of the pre-start hook starting up the bitcoind container early for Tor HS creation + # and creating the blocks directory. + if [[ ! -d "${BITCOIN_DATA_DIR}/blocks" ]] && [[ ! -d "${BITCOIN_DATA_DIR}/testnet3/blocks" ]] && [[ ! -d "${BITCOIN_DATA_DIR}/regtest/blocks" ]] then - BITCOIN_INSTALL_EXISTS="true" + touch "${IS_POST_ADVANCED_SETTINGS_INSTALL_FILE_PATH}" fi APP_CONFIG_EXISTS="false" if [[ -f "${EXPORTS_APP_DIR}/data/app/bitcoin-config.json" ]] then - APP_CONFIG_EXISTS="true" + APP_CONFIG_EXISTS="true" fi - if [[ "${BITCOIN_INSTALL_EXISTS}" = "true" ]] && [[ "${APP_CONFIG_EXISTS}" = "false" ]] + if [[ ! -f "${IS_POST_ADVANCED_SETTINGS_INSTALL_FILE_PATH}" ]] && [[ "${APP_CONFIG_EXISTS}" = "false" ]] then # This app is not a fresh install, it's being updated, so preserve existing clearnet over Tor setting export BITCOIN_INITIALIZE_WITH_CLEARNET_OVER_TOR="true"