#!/bin/sh set -e GENESIS_FILE="/app/genesis.json" DATADIR="/data" # Initialize geth datadir if not already done if [ ! -d "$DATADIR/geth/chaindata" ]; then echo "Initializing geth datadir with genesis block..." geth init --datadir "$DATADIR" "$GENESIS_FILE" fi # Import admin private key if provided and no accounts exist yet if [ -n "$ADMIN_PRIVATE_KEY" ]; then EXISTING_ACCOUNTS=$(geth account list --datadir "$DATADIR" 2>/dev/null || true) if [ -z "$EXISTING_ACCOUNTS" ]; then echo "Importing admin private key..." TMPKEY=$(mktemp) echo "$ADMIN_PRIVATE_KEY" > "$TMPKEY" geth account import --datadir "$DATADIR" --password /dev/null --lightkdf "$TMPKEY" rm -f "$TMPKEY" else echo "Account(s) already exist, skipping import." fi fi echo "Starting geth node..." exec geth \ --datadir "$DATADIR" \ --networkid 8888 \ --http \ --http.addr 0.0.0.0 \ --http.port 8545 \ --http.api eth,net,web3,personal,txpool \ --http.corsdomain "*" \ --http.vhosts "*" \ --ws \ --ws.addr 0.0.0.0 \ --ws.port 8546 \ --ws.api eth,net,web3 \ --ws.origins "*" \ --mine \ --miner.etherbase "$ADMIN_ADDRESS" \ --unlock "$ADMIN_ADDRESS" \ --password /dev/null \ --allow-insecure-unlock \ --nodiscover \ --maxpeers 0 \ --syncmode full \ --gcmode archive