From 32be64fb3609b5711f0f5f9171f086f197d7d6ef Mon Sep 17 00:00:00 2001 From: Gemini Bot Date: Tue, 20 Jan 2026 10:54:22 +0000 Subject: [PATCH] Add install script and update README with cgminer instructions --- README.md | 48 +++++++++++++++++++------- install.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 12 deletions(-) create mode 100755 install.sh diff --git a/README.md b/README.md index 86b2589..4c0178e 100644 --- a/README.md +++ b/README.md @@ -16,28 +16,52 @@ - Restart-Funktion - **Tech Stack:** Python Flask, Bootstrap 5 (Dark Mode), Vanilla JS. -## Installation +## Automatische Installation (Empfohlen) + +Das `install.sh` Skript übernimmt die komplette Einrichtung inkl. Kompilieren von `cgminer` (dmaxl Fork für Gridseed Support) und Einrichten der Systemd-Services. 1. Repository klonen: ```bash - git clone https://git.klenzel.net/admin/NecroHash.git /opt/necrohash - cd /opt/necrohash + git clone https://git.klenzel.net/admin/NecroHash.git necrohash_install + cd necrohash_install ``` -2. Starten: +2. Installer ausführen: ```bash - ./start_gui.sh + sudo ./install.sh + ``` + *Hinweis: Der Installer installiert Abhängigkeiten, kompiliert cgminer (falls nicht vorhanden), kopiert die Dateien nach `/opt/necrohash` und richtet Autostart ein.* + +3. Dienste Starten: + Nach der Installation sind die Dienste aktiviert aber müssen einmalig gestartet werden (oder Reboot): + ```bash + sudo systemctl start necrohash-gui + sudo systemctl start necrohash-miner ``` -3. Browser öffnen: `http://:5000` +4. Zugriff: + Öffnen Sie im Browser `http://:5000` -## Konfiguration +## Manuelle Installation -NecroHash nutzt den `cgminer` API-Server. Starten Sie `cgminer` mit der Konfiguration im Projektordner: +Falls Sie den Automatismus nicht nutzen wollen: -```bash -cgminer -c /opt/necrohash/cgminer.conf -``` +1. **Abhängigkeiten:** Python 3, `libusb-1.0-0-dev`, `libcurl4-openssl-dev`, `libncurses5-dev`. +2. **Cgminer:** Installieren Sie einen Gridseed-kompatiblen Fork (z.B. https://github.com/dmaxl/cgminer). + Configure flags: `./configure --enable-gridseed` +3. **App:** + - Code nach `/opt/necrohash` kopieren. + - `pip install -r requirements.txt` (in venv). +4. **Cgminer Config:** + Starten Sie cgminer zwingend mit der Config-Datei aus dem Web-Ordner, damit die GUI Einstellungen schreiben kann: + ```bash + cgminer -c /opt/necrohash/cgminer.conf + ``` + Die Config MUSS folgende API-Settings enthalten (Standard in NecroHash): + ```json + "api-listen": true, + "api-allow": "W:127.0.0.1" + ``` ## Lizenz -MIT \ No newline at end of file +MIT diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..067b01d --- /dev/null +++ b/install.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# NecroHash Installer +# Installiert NecroHash und richtet den Autostart ein. + +TARGET_DIR="/opt/necrohash" +USER="pi" + +if [ "$EUID" -ne 0 ]; then + echo "Bitte als root ausführen (sudo ./install.sh)" + exit 1 +fi + +echo "Installing NecroHash to $TARGET_DIR..." + +# 1. Systemabhängigkeiten +echo "Installing system dependencies..." +apt-get update +apt-get install -y python3 python3-venv git libncurses5-dev libudev-dev build-essential autoconf automake libtool pkg-config libcurl4-openssl-dev + +# 2. Cgminer Installation (dmaxl fork for Gridseed) +if [ ! -f "/usr/local/bin/cgminer" ]; then + echo "Compiling and installing cgminer for Gridseed..." + cd /tmp + git clone https://github.com/dmaxl/cgminer.git + cd cgminer + ./autogen.sh + ./configure --enable-gridseed + make + make install + cd .. + rm -rf cgminer +else + echo "cgminer found, skipping compilation." +fi + +# 3. NecroHash Dateien kopieren +if [ -d "$TARGET_DIR" ]; then + echo "Backup existing installation..." + mv "$TARGET_DIR" "${TARGET_DIR}_backup_$(date +%s)" +fi + +echo "Cloning/Copying NecroHash..." +# Wir gehen davon aus, dass wir im Repo-Ordner sind. Kopieren wir einfach alles rüber. +mkdir -p "$TARGET_DIR" +cp -r . "$TARGET_DIR" +chown -R $USER:$USER "$TARGET_DIR" + +# 4. Python Environment einrichten +echo "Setting up Python environment..." +su - $USER -c "cd $TARGET_DIR && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt" + +# 5. Systemd Services einrichten + +# GUI Service +cat < /etc/systemd/system/necrohash-gui.service +[Unit] +Description=NecroHash Web GUI +After=network.target + +[Service] +User=$USER +WorkingDirectory=$TARGET_DIR +ExecStart=$TARGET_DIR/start_gui.sh +Restart=always + +[Install] +WantedBy=multi-user.target +EOF + +# Mining Service +cat < /etc/systemd/system/necrohash-miner.service +[Unit] +Description=NecroHash Miner (cgminer) +After=network.target necrohash-gui.service + +[Service] +User=$USER +WorkingDirectory=$TARGET_DIR +# Screen session for optional attaching: screen -r necrohash +# ExecStart=screen -DmS necrohash /usr/local/bin/cgminer -c $TARGET_DIR/cgminer.conf +# Direct execution (better for logs/systemd): +ExecStart=/usr/local/bin/cgminer -c $TARGET_DIR/cgminer.conf +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF + +systemctl daemon-reload +systemctl enable necrohash-gui.service +systemctl enable necrohash-miner.service + +echo "Installation complete." +echo "Edit config at $TARGET_DIR/cgminer.conf" +echo "Start services with:" +echo " systemctl start necrohash-gui" +echo " systemctl start necrohash-miner"