Add mining mode selection (SHA256/Scrypt) via GUI
This commit is contained in:
17
app.py
17
app.py
@@ -17,7 +17,14 @@ def index():
|
|||||||
@app.route('/settings')
|
@app.route('/settings')
|
||||||
def settings():
|
def settings():
|
||||||
config = config_mgr.load_config()
|
config = config_mgr.load_config()
|
||||||
return render_template('settings.html', config=config, active_page='settings')
|
|
||||||
|
# Load mode
|
||||||
|
mode = 'sha256'
|
||||||
|
if os.path.exists('mining_mode.conf'):
|
||||||
|
with open('mining_mode.conf', 'r') as f:
|
||||||
|
mode = f.read().strip()
|
||||||
|
|
||||||
|
return render_template('settings.html', config=config, active_page='settings', mode=mode)
|
||||||
|
|
||||||
@app.route('/api/data')
|
@app.route('/api/data')
|
||||||
def api_data():
|
def api_data():
|
||||||
@@ -56,6 +63,14 @@ def save_settings():
|
|||||||
|
|
||||||
new_config = config_mgr.load_config() # Start with existing
|
new_config = config_mgr.load_config() # Start with existing
|
||||||
|
|
||||||
|
# Save mode
|
||||||
|
mode = request.form.get('mining_mode', 'sha256')
|
||||||
|
try:
|
||||||
|
with open('mining_mode.conf', 'w') as f:
|
||||||
|
f.write(mode)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error saving mode: {e}")
|
||||||
|
|
||||||
# Update simple fields
|
# Update simple fields
|
||||||
new_config['gridseed-options'] = f"freq={request.form.get('freq', '850')}"
|
new_config['gridseed-options'] = f"freq={request.form.get('freq', '850')}"
|
||||||
|
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ After=network.target necrohash-gui.service
|
|||||||
[Service]
|
[Service]
|
||||||
User=$USER
|
User=$USER
|
||||||
WorkingDirectory=$TARGET_DIR
|
WorkingDirectory=$TARGET_DIR
|
||||||
# Log stdout/stderr to file for the GUI to read
|
# Use wrapper script to handle mode switching (scrypt/sha256)
|
||||||
ExecStart=/bin/sh -c 'exec /usr/local/bin/cgminer --gridseed-options freq=850 -c $TARGET_DIR/cgminer.conf >> $TARGET_DIR/cgminer.log 2>&1'
|
ExecStart=$TARGET_DIR/miner_wrapper.sh
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
|||||||
36
miner_wrapper.sh
Executable file
36
miner_wrapper.sh
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Wrapper script to start cgminer with correct flags based on selected mode
|
||||||
|
|
||||||
|
MODE_FILE="mining_mode.conf"
|
||||||
|
CONF_FILE="cgminer.conf"
|
||||||
|
LOG_FILE="cgminer.log"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# Dual mode usually implies scrypt flag + gridseed options, but purely depends on cgminer version behavior.
|
||||||
|
# Often dual mode is default if scrypt is enabled?
|
||||||
|
# Actually for gridseed:
|
||||||
|
# SHA256 only: no --scrypt
|
||||||
|
# Scrypt only: --scrypt --gridseed-options=scrypt
|
||||||
|
# Dual: --scrypt --gridseed-options=... (default)
|
||||||
|
# Let's assume:
|
||||||
|
# SHA256: (no scrypt flag)
|
||||||
|
# Scrypt: --scrypt
|
||||||
|
FLAGS="--scrypt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting miner in mode: $MODE with flags: $FLAGS" > "$LOG_FILE"
|
||||||
|
|
||||||
|
# Execute cgminer
|
||||||
|
# Note: we use exec to replace the shell process
|
||||||
|
exec /usr/local/bin/cgminer $FLAGS --gridseed-options freq=850 -c "$CONF_FILE" >> "$LOG_FILE" 2>&1
|
||||||
@@ -17,6 +17,18 @@
|
|||||||
<div class="card-header border-secondary">Konfiguration</div>
|
<div class="card-header border-secondary">Konfiguration</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form action="{{ url_for('save_settings') }}" method="POST">
|
<form action="{{ url_for('save_settings') }}" method="POST">
|
||||||
|
<h5 class="card-title text-info mb-3">Allgemein</h5>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="mining_mode" class="form-label text-white">Mining Modus</label>
|
||||||
|
<select class="form-select bg-black text-white border-secondary" id="mining_mode" name="mining_mode">
|
||||||
|
<option value="sha256" {% if mode == 'sha256' %}selected{% endif %}>SHA-256 (Bitcoin / Peercoin)</option>
|
||||||
|
<option value="scrypt" {% if mode == 'scrypt' %}selected{% endif %}>Scrypt (Litecoin / Dogecoin)</option>
|
||||||
|
</select>
|
||||||
|
<div class="form-text text-muted">Ändert das Startverhalten des Miners.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr class="border-secondary">
|
||||||
<h5 class="card-title text-info mb-3">Pool Einstellungen</h5>
|
<h5 class="card-title text-info mb-3">Pool Einstellungen</h5>
|
||||||
|
|
||||||
<!-- Assuming single pool editing for MVP -->
|
<!-- Assuming single pool editing for MVP -->
|
||||||
|
|||||||
Reference in New Issue
Block a user