#!/bin/bash # GMiner algorithm test script - save as test_gminer.sh # Default docker image (can be overridden with parameter) DOCKER_IMAGE=${1:-"amdopencl"} # amd-strix-halo-llama-rocm #amd-strix-halo-llama-vulkan-radv # amd-strix-halo-llama-vulkan-amdvlk BTC_WALLET="bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j" # Algorithm to coin mapping declare -A ALGO_COINS=( ["ethash"]="ETH" ["etchash"]="ETC" ["autolykos2"]="ERG" ["ergo"]="ERG" ["equihash125_4"]="ZEL" ["equihash144_5"]="ZEL" ["equihash192_7"]="ZEL" ["equihash210_9"]="ZEL" ["beamhash"]="BEAM" ["cuckaroo29"]="GRIN" ["cuckatoo32"]="GRIN" ["flux"]="FLUX" ["octopus"]="CFX" ) # Function to fetch current cryptocurrency prices fetch_prices() { echo "Fetching current cryptocurrency prices..." # Use CoinGecko API to get current prices local api_url="https://api.coingecko.com/api/v3/simple/price?ids=ethereum,ethereum-classic,ergo,zelcash,beam,grin,flux,conflux&vs_currencies=usd" # Try to fetch prices with timeout and fallback local prices_json=$(timeout 10s curl -s "$api_url" 2>/dev/null) if [[ -z "$prices_json" ]]; then echo "Warning: Could not fetch current prices, using fallback values" PRICES_ETH=3500.00 PRICES_ETC=35.00 PRICES_ERG=2.50 PRICES_ZEL=0.15 PRICES_BEAM=0.05 PRICES_GRIN=0.05 PRICES_FLUX=0.80 PRICES_CFX=0.20 return fi # Parse JSON response and extract prices using jq if available, otherwise use grep if command -v jq &> /dev/null; then PRICES_ETH=$(echo "$prices_json" | jq -r '.ethereum.usd // "3500.00"') PRICES_ETC=$(echo "$prices_json" | jq -r '.ethereum-classic.usd // "35.00"') PRICES_ERG=$(echo "$prices_json" | jq -r '.ergo.usd // "2.50"') PRICES_ZEL=$(echo "$prices_json" | jq -r '.zelcash.usd // "0.15"') PRICES_BEAM=$(echo "$prices_json" | jq -r '.beam.usd // "0.05"') PRICES_GRIN=$(echo "$prices_json" | jq -r '.grin.usd // "0.05"') PRICES_FLUX=$(echo "$prices_json" | jq -r '.flux.usd // "0.80"') PRICES_CFX=$(echo "$prices_json" | jq -r '.conflux.usd // "0.20"') else # Fallback to grep parsing PRICES_ETH=$(echo "$prices_json" | grep -o '"ethereum":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "3500.00") PRICES_ETC=$(echo "$prices_json" | grep -o '"ethereum-classic":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "35.00") PRICES_ERG=$(echo "$prices_json" | grep -o '"ergo":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "2.50") PRICES_ZEL=$(echo "$prices_json" | grep -o '"zelcash":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "0.15") PRICES_BEAM=$(echo "$prices_json" | grep -o '"beam":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "0.05") PRICES_GRIN=$(echo "$prices_json" | grep -o '"grin":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "0.05") PRICES_FLUX=$(echo "$prices_json" | grep -o '"flux":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "0.80") PRICES_CFX=$(echo "$prices_json" | grep -o '"conflux":{"usd":[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*$' || echo "0.20") fi echo "Current prices fetched successfully:" echo " ETH: $PRICES_ETH" echo " ETC: $PRICES_ETC" echo " ERG: $PRICES_ERG" echo " ZEL: $PRICES_ZEL" echo " BEAM: $PRICES_BEAM" echo " GRIN: $PRICES_GRIN" echo " FLUX: $PRICES_FLUX" echo " CFX: $PRICES_CFX" echo "" } # GMiner supported algorithms ALGOS=( "ethash" "etchash" "autolykos2" "equihash125_4" "equihash144_5" "equihash192_7" "equihash210_9" "beamhash" "cuckaroo29" "cuckatoo32" "flux" "octopus" "ergo" ) echo "=== GMiner Algorithm Tests ===" echo "Using BTC wallet: $BTC_WALLET" echo "Using Docker image: $DOCKER_IMAGE" echo "Testing each algorithm for 30 seconds..." echo "=======================================" # Fetch current prices at startup fetch_prices # Function to calculate USD value calculate_usd_reward() { local algo=$1 local hashrate=$2 local coin=${ALGO_COINS[$algo]} # Get price based on coin local price=0 case $coin in "ETH") price=$PRICES_ETH ;; "ETC") price=$PRICES_ETC ;; "ERG") price=$PRICES_ERG ;; "ZEL") price=$PRICES_ZEL ;; "BEAM") price=$PRICES_BEAM ;; "GRIN") price=$PRICES_GRIN ;; "FLUX") price=$PRICES_FLUX ;; "CFX") price=$PRICES_CFX ;; *) echo "Unknown" && return ;; esac if [[ -z "$price" || "$price" == "0" ]]; then echo "Unknown" return fi # Rough calculation: hashrate * price * 0.000001 (simplified) local usd_value=$(echo "$hashrate * $price * 0.000001" | bc -l 2>/dev/null) printf "%.2f" $usd_value 2>/dev/null || echo "Unknown" } # Function to extract hashrate from miner output extract_hashrate() { local output="$1" # Look for common hashrate patterns in GMiner output local hashrate=$(echo "$output" | grep -oE "[0-9]+\.[0-9]+ [KMGT]?H/s" | tail -1 | grep -oE "[0-9]+\.[0-9]+" | tail -1) # If no decimal found, look for integer hashrates if [[ -z "$hashrate" ]]; then hashrate=$(echo "$output" | grep -oE "[0-9]+ [KMGT]?H/s" | tail -1 | grep -oE "[0-9]+" | tail -1) fi # If still no hashrate found, look for any number followed by H/s if [[ -z "$hashrate" ]]; then hashrate=$(echo "$output" | grep -oE "[0-9]+[\.]?[0-9]* H/s" | tail -1 | grep -oE "[0-9]+[\.]?[0-9]*" | tail -1) fi # If still no hashrate, look for "Speed:" patterns if [[ -z "$hashrate" ]]; then hashrate=$(echo "$output" | grep -i "speed:" | tail -1 | grep -oE "[0-9]+[\.]?[0-9]*" | tail -1) fi # If still no hashrate, look for any number followed by H/s (case insensitive) if [[ -z "$hashrate" ]]; then hashrate=$(echo "$output" | grep -ioE "[0-9]+[\.]?[0-9]* h/s" | tail -1 | grep -oE "[0-9]+[\.]?[0-9]*" | tail -1) fi echo "$hashrate" } for algo in "${ALGOS[@]}"; do echo "" echo "Testing: $algo" echo "------------------------" case $algo in "ethash") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server eth.2miners.com:2020 --user '$BTC_WALLET' --pass x" 2>&1) ;; "etchash") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server etc.2miners.com:1010 --user '$BTC_WALLET' --pass x" 2>&1) ;; "autolykos2"|"ergo") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo autolykos2 --server ergo.2miners.com:8888 --user '$BTC_WALLET' --pass x" 2>&1) ;; "equihash125_4") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server zel.2miners.com:9090 --user '$BTC_WALLET' --pass x" 2>&1) ;; "equihash144_5") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server zel.2miners.com:9090 --user '$BTC_WALLET' --pass x" 2>&1) ;; "equihash192_7") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server zel.2miners.com:9090 --user '$BTC_WALLET' --pass x" 2>&1) ;; "equihash210_9") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server zel.2miners.com:9090 --user '$BTC_WALLET' --pass x" 2>&1) ;; "beamhash") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server beam.2miners.com:5252 --user '$BTC_WALLET' --pass x" 2>&1) ;; "cuckaroo29") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server grin.2miners.com:3030 --user '$BTC_WALLET' --pass x" 2>&1) ;; "cuckatoo32") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server grin.2miners.com:3030 --user '$BTC_WALLET' --pass x" 2>&1) ;; "flux") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server flux.2miners.com:2020 --user '$BTC_WALLET' --pass x" 2>&1) ;; "octopus") output=$(sudo docker exec -it $DOCKER_IMAGE timeout 35s bash -c "/mnt/dl/gminer/miner --algo $algo --server cfx.2miners.com:3254 --user '$BTC_WALLET' --pass x" 2>&1) ;; *) echo "No specific pool configured for $algo - skipping" continue ;; esac exit_code=$? # Extract hashrate and calculate USD value hashrate=$(extract_hashrate "$output") coin=${ALGO_COINS[$algo]} usd_value=$(calculate_usd_reward "$algo" "$hashrate") if [ $exit_code -eq 0 ]; then echo "SUCCESS: $algo - Hashrate: ${hashrate}H/s - Coin: $coin - Est. USD/day: $usd_value" elif [ $exit_code -eq 124 ]; then echo "TIMEOUT: $algo - Hashrate: ${hashrate}H/s - Coin: $coin - Est. USD/day: $usd_value (likely working)" else echo "FAILED: $algo - Error code: $exit_code" # Debug: show first few lines of output for failed attempts echo "Debug output (first 5 lines):" echo "$output" | head -5 fi sleep 3 done echo "" echo "=== GMiner Tests Complete ===" echo "Usage: $0 [docker_image_name]" echo "Default: amdopencl" echo "Example for RockM: $0 rockm"