From 1786cf730c322b48384cb33cdbef8985c3baf491 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Sun, 3 May 2026 11:43:06 +0200 Subject: [PATCH] feat: Installer-Script fuer Debian 13 Einzeiler-Installation: curl -s https://git.cynfo.net/christian/busylight_modular/raw/branch/master/install.sh | bash Co-Authored-By: Claude Opus 4.6 (1M context) --- install.sh | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..fa0f5f0 --- /dev/null +++ b/install.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Busylight Modular - Installer fuer Debian 13 (Trixie) +# Verwendung: curl -s https://git.cynfo.net/christian/busylight_modular/raw/branch/master/install.sh | bash + +set -e + +REPO_URL="https://git.cynfo.net/christian/busylight_modular.git" +INSTALL_DIR="/opt/busylight" +SERVICE_USER="busylight" + +echo "==========================================" +echo " Busylight Modular - Installer" +echo "==========================================" +echo "" + +# Root-Check +if [ "$(id -u)" -ne 0 ]; then + echo "FEHLER: Bitte als root ausfuehren." + exit 1 +fi + +# OS-Check +if [ ! -f /etc/debian_version ]; then + echo "WARNUNG: Kein Debian erkannt. Fortfahren auf eigene Gefahr." +fi + +echo "[1/6] Pakete installieren..." +apt-get update -qq +apt-get install -y -qq python3 python3-venv python3-pip git curl > /dev/null 2>&1 +echo " OK" + +echo "[2/6] Benutzer '$SERVICE_USER' erstellen..." +if id "$SERVICE_USER" &>/dev/null; then + echo " Benutzer existiert bereits" +else + useradd -r -m -d "$INSTALL_DIR" -s /bin/bash "$SERVICE_USER" + echo " OK" +fi + +echo "[3/6] Repository klonen nach $INSTALL_DIR..." +if [ -d "$INSTALL_DIR/.git" ]; then + echo " Repository existiert bereits, aktualisiere..." + cd "$INSTALL_DIR" + git config --global --add safe.directory "$INSTALL_DIR" 2>/dev/null + git pull +else + mkdir -p "$INSTALL_DIR" + git clone "$REPO_URL" "$INSTALL_DIR" +fi +chown -R "$SERVICE_USER:$SERVICE_USER" "$INSTALL_DIR" +echo " OK" + +echo "[4/6] Python Virtual Environment einrichten..." +cd "$INSTALL_DIR" +su - "$SERVICE_USER" -c "cd $INSTALL_DIR && python3 -m venv venv && source venv/bin/activate && pip install -q -r requirements.txt" +echo " OK" + +echo "[5/6] systemd Service installieren..." +cp "$INSTALL_DIR/busylight.service" /etc/systemd/system/ +systemctl daemon-reload +systemctl enable busylight +echo " OK" + +echo "[6/6] Service starten..." +systemctl restart busylight +sleep 2 + +# Status pruefen +if systemctl is-active --quiet busylight; then + echo " OK - Service laeuft" +else + echo " WARNUNG: Service konnte nicht gestartet werden" + echo " Pruefe: journalctl -u busylight -n 20" +fi + +# IP ermitteln +IP=$(hostname -I | awk '{print $1}') + +echo "" +echo "==========================================" +echo " Installation abgeschlossen!" +echo "==========================================" +echo "" +echo " Web-Interface: http://${IP}:8080" +echo " Webhook-API: http://${IP}:8081" +echo "" +echo " Naechste Schritte:" +echo " 1. Web-Interface oeffnen" +echo " 2. Unter Einstellungen Azure Credentials eintragen" +echo " 3. Mit Azure verbinden (Button)" +echo " 4. Benutzer synchronisieren" +echo " 5. WLED-Geraete hinzufuegen" +echo " 6. Zuordnungen erstellen" +echo "" +echo " Update: cd $INSTALL_DIR && git pull && sudo systemctl restart busylight" +echo " Logs: journalctl -u busylight -f" +echo " Status: systemctl status busylight" +echo ""