Add install script and update README with cgminer instructions
Some checks failed
Docker Build & Push / build-and-push (push) Failing after 5s
Some checks failed
Docker Build & Push / build-and-push (push) Failing after 5s
This commit is contained in:
99
install.sh
Executable file
99
install.sh
Executable file
@@ -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 <<EOF > /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 <<EOF > /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"
|
||||
Reference in New Issue
Block a user