#!/bin/bash
set -e

# Detect available binary (XDC or geth)
if command -v XDC >/dev/null 2>&1; then
    BINARY="XDC"
elif command -v geth >/dev/null 2>&1; then
    BINARY="geth"
else
    echo "ERROR: No XDC or geth binary found in PATH"
    exit 1
fi

# If a start script exists at /work/start.sh, use it
if [ -f /work/start.sh ]; then
    exec bash /work/start.sh "$@"
fi

# Otherwise, directly execute the detected binary with passed arguments
exec /usr/local/bin/$BINARY "$@"
