#!/bin/bash # Wrapper script to start cgminer with correct flags based on selected mode # Ensure we are in the script directory cd "$(dirname "$0")" MODE_FILE="mining_mode.conf" CONF_FILE="cgminer.conf" LOG_FILE="cgminer.log" # Kill any existing instances that might block the port/device killall -9 cgminer 2>/dev/null sleep 1 # Cleanup stale semaphore locks from potential crashes rm -f /tmp/cgminer-usb-* # Default mode MODE="sha256" if [ -f "$MODE_FILE" ]; then MODE=$(cat "$MODE_FILE" | tr -d '[:space:]') fi FLAGS="" if [ "$MODE" == "scrypt" ]; then FLAGS="--scrypt" elif [ "$MODE" == "dual" ]; then FLAGS="--scrypt" else # SHA256 Mode # Some forks require explicitly disabling scrypt via config or lack of flag. # We ensure no scrypt flag is passed. FLAGS="" fi # Ensure correct pool is used (Debugging hint) echo "[$(date)] Starting miner in mode: $MODE with flags: '$FLAGS'" >> "$LOG_FILE" echo "[$(date)] Config file: $CONF_FILE" >> "$LOG_FILE" # Execute cgminer # Forced API listening via command line args to ensure it's active # Added --api-allow W:127.0.0.1 explicitly just in case config is ignored exec /usr/local/bin/cgminer $FLAGS --gridseed-options freq=850 --api-listen --api-allow W:127.0.0.1 -c "$CONF_FILE" >> "$LOG_FILE" 2>&1