Initial StartOS 0.3.5.1 packaging scaffold for Kamado Pool
Multi-stage Dockerfile clones KamadoPool at a pinned SHA, builds ckpool and kamado-api (with embedded Svelte UI), runtime image supervises both processes via tini + wait -n. Config covers bitcoind mainnet/testnet4 variant, payout address, coinbase tag, vardiff knobs, and log level. Web UI interface only — stratum :3333 requires a router port-forward or simpleproxy workaround because StartOS 0.3.x does not forward raw TCP on LAN. TODO before first build: pin KAMADO_REPO + KAMADO_SHA in the Dockerfile to a pushed commit.
This commit is contained in:
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/bin/bash
|
||||
# Kamado Pool StartOS entrypoint.
|
||||
#
|
||||
# Renders ckpool.conf from /root/.kamado/start9/config.yaml, resolves
|
||||
# which bitcoind variant the user picked (mainnet vs testnet4), then
|
||||
# supervises ckpool and kamado-api as a pair — if either exits, tear
|
||||
# the container down so StartOS restarts the service cleanly.
|
||||
set -euo pipefail
|
||||
|
||||
CONFIG_FILE="/root/.kamado/start9/config.yaml"
|
||||
CKPOOL_DIR="/root/.ckpool"
|
||||
CKPOOL_CONF="${CKPOOL_DIR}/ckpool.conf"
|
||||
CKPOOL_LOG_DIR="${CKPOOL_DIR}/logs"
|
||||
mkdir -p "${CKPOOL_DIR}" "${CKPOOL_LOG_DIR}"
|
||||
|
||||
if [[ ! -f "${CONFIG_FILE}" ]]; then
|
||||
echo "kamado-entrypoint: config file missing: ${CONFIG_FILE}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
q() { yq -r "$1" "${CONFIG_FILE}"; }
|
||||
|
||||
BITCOIND_VARIANT=$(q '.bitcoind.type')
|
||||
case "${BITCOIND_VARIANT}" in
|
||||
bitcoind)
|
||||
BITCOIN_HOST="bitcoind.embassy"
|
||||
BITCOIN_PORT=8332
|
||||
;;
|
||||
bitcoind-testnet)
|
||||
BITCOIN_HOST="bitcoind-testnet.embassy"
|
||||
BITCOIN_PORT=48332
|
||||
;;
|
||||
*)
|
||||
echo "kamado-entrypoint: unknown bitcoind variant: ${BITCOIND_VARIANT}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
BITCOIN_USER=$(q '.bitcoind.user')
|
||||
BITCOIN_PASS=$(q '.bitcoind.password')
|
||||
POOL_BTCADDRESS=$(q '.pool-address')
|
||||
POOL_IDENTIFIER=$(q '.pool-identifier')
|
||||
DROPIDLE=$(q '.dropidle // 0')
|
||||
STARTDIFF=$(q '.startdiff // 16384')
|
||||
MINDIFF=$(q '.mindiff // 1000')
|
||||
MAXDIFF=$(q '.maxdiff // 0')
|
||||
LOG_LEVEL=$(q '.log-level // "info"')
|
||||
|
||||
cat > "${CKPOOL_CONF}" <<EOF
|
||||
{
|
||||
"btcd": [
|
||||
{
|
||||
"url": "${BITCOIN_HOST}:${BITCOIN_PORT}",
|
||||
"auth": "${BITCOIN_USER}",
|
||||
"pass": "${BITCOIN_PASS}",
|
||||
"notify": true
|
||||
}
|
||||
],
|
||||
"btcaddress": "${POOL_BTCADDRESS}",
|
||||
"btcsig": "${POOL_IDENTIFIER}",
|
||||
"serverurl": [
|
||||
"0.0.0.0:3333"
|
||||
],
|
||||
"mindiff": ${MINDIFF},
|
||||
"startdiff": ${STARTDIFF},
|
||||
"maxdiff": ${MAXDIFF},
|
||||
"logdir": "${CKPOOL_LOG_DIR}"
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "kamado-entrypoint: starting ckpool (solo, ${BITCOIND_VARIANT})"
|
||||
ckpool -B -c "${CKPOOL_CONF}" &
|
||||
CKPOOL_PID=$!
|
||||
|
||||
export KAMADO_CKPOOL_SOCKET="${CKPOOL_DIR}/solo/listener"
|
||||
export KAMADO_CKPOOL_LOGFILE="${CKPOOL_LOG_DIR}/ckpool.log"
|
||||
export KAMADO_BITCOIND_URL="http://${BITCOIN_HOST}:${BITCOIN_PORT}"
|
||||
export KAMADO_BITCOIND_USER="${BITCOIN_USER}"
|
||||
export KAMADO_BITCOIND_PASS="${BITCOIN_PASS}"
|
||||
export KAMADO_HTTP_ADDR=":8080"
|
||||
export KAMADO_LOG_LEVEL="${LOG_LEVEL}"
|
||||
|
||||
echo "kamado-entrypoint: starting kamado-api"
|
||||
kamado-api &
|
||||
API_PID=$!
|
||||
|
||||
term() {
|
||||
echo "kamado-entrypoint: SIGTERM — shutting down"
|
||||
kill -TERM "${API_PID}" "${CKPOOL_PID}" 2>/dev/null || true
|
||||
wait "${API_PID}" "${CKPOOL_PID}" 2>/dev/null || true
|
||||
exit 0
|
||||
}
|
||||
trap term TERM INT
|
||||
|
||||
wait -n "${CKPOOL_PID}" "${API_PID}"
|
||||
EXIT_CODE=$?
|
||||
echo "kamado-entrypoint: one of ckpool/kamado-api exited (${EXIT_CODE}), stopping the other"
|
||||
kill -TERM "${API_PID}" "${CKPOOL_PID}" 2>/dev/null || true
|
||||
wait || true
|
||||
exit "${EXIT_CODE}"
|
||||
Reference in New Issue
Block a user