umbrel-apps/bitcoin-knots/hooks/pre-start
Léo Haf 6b62dd23e0
App Submission: Bitcoin Knots (#953)
Co-authored-by: smolgrrr <smolgrrr@protonmail.com>
Co-authored-by: nmfretz <nmfretz@gmail.com>
2024-03-25 23:52:20 -07:00

26 lines
691 B
Bash
Executable File

#!/usr/bin/env bash
# Delay booting Bitcoin until the RPC and P2P Tor Hidden Services are ready
HIDDEN_SERVICE_FILE="${TOR_DATA_DIR}/app-${APP_ID}-rpc/hostname"
if [[ -f "${HIDDEN_SERVICE_FILE}" ]]; then
exit
fi
"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" up --detach bitcoind
"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" up --detach tor
echo "App: ${APP_ID} - Generating Tor Hidden Service..."
for attempt in $(seq 1 100); do
if [[ -f "${HIDDEN_SERVICE_FILE}" ]]; then
echo "App: ${APP_ID} - Hidden service file created successfully!"
break
fi
sleep 0.1
done
if [[ ! -f "${HIDDEN_SERVICE_FILE}" ]]; then
echo "App: ${APP_ID} - Hidden service file wasn't created"
fi