Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docker/knots/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,35 @@
# This script acts as an entrypoint for the bitcoind container.
# It retrieves RPC credentials and other configurations from environment
# variables, generates a bitcoin.conf file, and then starts bitcoind.
#
# Network Configuration:
# - Set NETWORK environment variable to: mainnet (default), testnet, or regtest
# - Invalid network values will cause the script to exit with an error

set -e

# Default Bitcoin data directory, should match DIR in Dockerfile
BITCOIN_DATA_DIR=${BITCOIN_DATA_DIR:-/data/.bitcoin}
CONFIG_FILE="${BITCOIN_DATA_DIR}/bitcoin.conf"

# Network configuration - validate network setting
NETWORK=${NETWORK:-mainnet}
case "${NETWORK}" in
mainnet)
echo "Starting bitcoind on mainnet"
;;
testnet)
echo "Starting bitcoind on testnet"
;;
regtest)
echo "Starting bitcoind on regtest"
;;
*)
echo "Error: Invalid NETWORK value '${NETWORK}'. Must be one of: mainnet, testnet, regtest"
exit 1
;;
esac

# Use provided RPC user/password or fallback to defaults
RPC_USER=${RPC_USER:-rpcuser}
RPC_PASSWORD=${RPC_PASSWORD:-rpcpassword}
Expand Down Expand Up @@ -70,6 +92,24 @@ cat << EOF > "$CONFIG_FILE"
# Bitcoin Core Configuration File
# Generated by entrypoint.sh

# ======== Network Configuration ========
EOF

# Add network-specific configuration
case "${NETWORK}" in
testnet)
echo "testnet=1" >> "$CONFIG_FILE"
;;
regtest)
echo "regtest=1" >> "$CONFIG_FILE"
;;
mainnet)
# No additional configuration needed for mainnet (default)
;;
esac

cat << EOF >> "$CONFIG_FILE"

# ======== Core Settings ========
server=${SERVER_ENABLED}
txindex=${TXINDEX_ENABLED}
Expand Down
Loading