Skip to content

Instantly share code, notes, and snippets.

@lorepozo
Last active September 10, 2017 18:25
Show Gist options
  • Save lorepozo/89588e411c5abe314618f63b270afb31 to your computer and use it in GitHub Desktop.
Save lorepozo/89588e411c5abe314618f63b270afb31 to your computer and use it in GitHub Desktop.
auto-switching best-profit GPU mining on GNU+Linux
#!/bin/sh
# REQUIRES jq (https://stedolan.github.io/jq)
# AND ccminer (https://github.com/tpruvot/ccminer)
# AND eqm (https://github.com/nicehash/nheqminer)
# (all in PATH)
#
# This program auto-switches miners for best profit.
#
# Copyright 2017 Lucas Morales <lucas@lucasem.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# donations welcome!
# btc:1FfJLQaArZmyfSULPXcDXJobGghf3PRqYD
# zec:t1YNLtZAQ59mzjYbFy1RfLjkkk4T967cSCn
### CONSTANTS (set these) ###
BTC_ADDR=1FfJLQaArZmyfSULPXcDXJobGghf3PRqYD
REGION=usa # nicehash region
NOTIFY= # notify-send or similar
CALC_DATA= # occupy the following with your appropriate stats
CALC_DATA+="&fa0=0" # scrypt (MH/s)
CALC_DATA+="&fa1=0" # sha256 (TH/s)
CALC_DATA+="&fa2=0" # scryptnf (MH/s)
CALC_DATA+="&fa3=23.3" # x11 (MH/s)
CALC_DATA+="&fa4=17.6" # x13 (MH/s)
CALC_DATA+="&fa5=1150" # keccak (MH/s)
CALC_DATA+="&fa6=17.1" # x15 (MH/s)
CALC_DATA+="&fa7=70" # nist5 (MH/s)
CALC_DATA+="&fa8=1.8" # neoscrypt (MH/s)
CALC_DATA+="&fa9=10" # lyra2re (MH/s)
CALC_DATA+="&fa10=150" # whirlpoolx (MH/s)
CALC_DATA+="&fa11=34" # qubit (MH/s)
CALC_DATA+="&fa12=0" # quark (MH/s)
CALC_DATA+="&fa13=0" # axiom (kH/s)
CALC_DATA+="&fa14=64" # lyra2rev2 (MH/s)
CALC_DATA+="&fa15=2.18" # scryptjanenf16 (kH/s)
CALC_DATA+="&fa16=15.5" # blake256r8 (GH/s)
CALC_DATA+="&fa17=0" # blake256r14 (GH/s)
CALC_DATA+="&fa18=0" # blake256r8vnl (GH/s)
CALC_DATA+="&fa19=0" # hodl (kH/s)
CALC_DATA+="&fa20=0" # daggerhashimoto (MH/s)
CALC_DATA+="&fa21=0" # decred (GH/s)
CALC_DATA+="&fa22=0" # cryptonight (kH/s)
CALC_DATA+="&fa23=0.53" # lbry (GH/s)
CALC_DATA+="&fa24=630" # equihash (Sol/s)
CALC_DATA+="&fa25=0" # pascal (GH/s)
CALC_DATA+="&fa26=16.3" # x11gost (MH/s)
CALC_DATA+="&fa27=0" # sia (GH/s)
CALC_DATA+="&fa28=0" # blake2s (GH/s)
### END CONSTANTS ###
algo_names=( scrypt sha256 scryptnf x11 x13 keccak x15 nist5 neoscrypt lyra2re whirlpoolx qubit quark axiom lyra2rev2 scryptjanenf16 blake256r8 blake256r14 blake256r8vnl hodl daggerhashimoto decred cryptonight lbry equihash pascal x11gost sia blake2s )
algo_ports=( 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 )
algo_algos=( scrypt sha256d FAIL x11 x13 keccak x15 nist5 neoscrypt lyra2 whielpool qubit FAIL FAIL lyra2v2 scrypt-jane blakecoin FAIL FAIL FAIL FAIL decred cryptonight lbry equihash FAIL sib sia FAIL )
current_algo=none
current_pid=
current_bin=
while true
do
algo_idx=$( curl -s 'https://www.nicehash.com/calc' -XPOST --data $CALC_DATA | jq .current_algo )
name=${algo_names[$algo_idx]}
port=${algo_ports[$algo_idx]}
algo=${algo_algos[$algo_idx]}
# new algo
if [ "$current_algo" != $algo ] && [ $algo != FAIL ]
then
# kill old miner
if [ -n "$current_pid" ]
then
case $current_bin in
eqm )
killall -9 eqm # eqm does not politely terminate
;;
* )
kill $current_pid
;;
esac
fi
if command -v "$NOTIFY" &>/dev/null
then $NOTIFY "mine" "switching from $current_algo to $algo"
fi
echo ; echo ; echo
echo =======================================
echo "switching from $current_algo to $algo"
echo =======================================
echo ; echo ; echo
# set cuda devices (some algos can't successfully double up)
case "$algo" in
blakecoin | decred | lyra2v2 | neoscrypt | x11 | x13 | x15 )
devices=0,0
;;
* )
devices=0
;;
esac
# spawn new miner
case "$algo" in
equihash )
eqm -l $REGION -t 0 -u $BTC_ADDR -w gpu -ca -ca &
current_pid=$!
current_bin=eqm
;;
*)
ccminer --url "stratum+tcp://$name.$REGION.nicehash.com:$port" \
--user "$BTC_ADDR.gpu" \
--algo $algo --devices $devices \
--gpu-clock=1700 --mem-clock=11000 --plimit=300W &
current_pid=$!
current_bin=ccminer
;;
esac
current_algo=$algo
else echo "========== no algo change ($algo) =========="
fi
sleep 60 # update every minute
done
@lorepozo
Copy link
Author

See lucasem/cryptocurrency-things for an up-to-date version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment