#!/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 # 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" fi echo "[$(date)] Starting miner in mode: $MODE with flags: $FLAGS" >> "$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