Skip to content

Instantly share code, notes, and snippets.

@skwp
Created October 2, 2018 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skwp/4b372f480cfa959107471e30ebb6a6c6 to your computer and use it in GitHub Desktop.
Save skwp/4b372f480cfa959107471e30ebb6a6c6 to your computer and use it in GitHub Desktop.
# Turn on mining if needed
if [[ "$TAG_mining" == "true" ]]; then
log "Enabling mining on this node..."
if [[ "$TAG_mining_type" == "cpuminer" ]]; then
bitcoinExec getnewaddress
docker run -d --name miner wernight/cpuminer-multi:alpine cpuminer -a sha256d -o http://$DOCKER_HOST_ADDRESS:9332 -O $TAG_rpcuser:$TAG_rpcpassword --coinbase-addr=$bitcoinExecResult --no-longpoll --no-stratum --no-extranonce --no-getwork
else
mining_rpc_call="setgenerate true $TAG_mining_cores"
mining_command="docker exec bitcoin /usr/local/bin/bitcoin-cli -rpcuser=$TAG_rpcuser -rpcpassword=$TAG_rpcpassword $mining_rpc_call"
# Turn on mining now
$($mining_command)
# Turn on mining every min in case we crash
echo "*/1 * * * * $mining_command" > miningOn.cron; crontab miningOn.cron
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment