#!/bin/bash # ============================================================================= # JH Photomaton — Script d'installation # Raspberry Pi 4 / Raspberry Pi OS (Debian Trixie) # ============================================================================= set -euo pipefail INSTALL_DIR="/home/pi/jh-photomaton" SERVICE_USER="root" # rpi_ws281x nécessite /dev/mem (root) VENV_DIR="$INSTALL_DIR/.venv" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo " JH Photomaton — Installation" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" # ── Vérifications ───────────────────────────────────────────────────────────── if [[ $EUID -ne 0 ]]; then echo "❌ Ce script doit être exécuté en root : sudo bash install.sh" exit 1 fi # ── Dépendances système ─────────────────────────────────────────────────────── echo "" echo "▶ Installation des dépendances système..." apt-get update -qq apt-get install -y --no-install-recommends \ python3 python3-pip python3-venv python3-dev \ python3-gpiozero python3-pigpio \ imagemagick \ cups cups-client \ git curl # ── rpi_ws281x : dépendances build ─────────────────────────────────────────── echo "" echo "▶ Installation de rpi_ws281x (LEDs WS2812)..." apt-get install -y --no-install-recommends \ gcc make build-essential \ scons swig # ── Désactiver audio si conflit GPIO18 ─────────────────────────────────────── # WS2812 sur GPIO18 (PWM) entre en conflit avec le son if ! grep -q "dtparam=audio=off" /boot/firmware/config.txt 2>/dev/null; then echo "dtparam=audio=off" >> /boot/firmware/config.txt echo "ℹ️ Audio désactivé dans /boot/firmware/config.txt (conflit GPIO18)" fi # ── Copie des fichiers ──────────────────────────────────────────────────────── echo "" echo "▶ Copie des fichiers vers $INSTALL_DIR..." SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" mkdir -p "$INSTALL_DIR" rsync -a --exclude='.venv' --exclude='__pycache__' --exclude='*.pyc' \ --exclude='data/*.db' \ "$PROJECT_DIR/" "$INSTALL_DIR/" mkdir -p "$INSTALL_DIR/data" # ── Environnement virtuel Python ────────────────────────────────────────────── echo "" echo "▶ Création de l'environnement virtuel Python..." python3 -m venv "$VENV_DIR" --system-site-packages # Le venv est créé par root (sudo) — le remettre à pi pour que pip fonctionne sans sudo chown -R pi:pi "$VENV_DIR" "$VENV_DIR/bin/pip" install --upgrade pip -q # Force jinja2 dans le venv pour ecraser la version systeme Debian # (la version systeme sur Trixie a un bug LRUCache incompatible avec Starlette) "$VENV_DIR/bin/pip" install --upgrade --ignore-installed jinja2 -q "$VENV_DIR/bin/pip" install -r "$INSTALL_DIR/requirements.txt" -q # rpi_ws281x (nécessite les headers, installé depuis PyPI) "$VENV_DIR/bin/pip" install rpi-ws281x -q || echo "⚠️ rpi_ws281x non installé (mode mock actif)" echo "" echo "▶ Dépendances Python installées." # ── Permissions /dev/mem pour rpi_ws281x ───────────────────────────────────── # Option : ajouter une règle udev pour éviter de tourner en root # Ici on tourne en root via systemd pour simplifier # ── Service systemd ─────────────────────────────────────────────────────────── echo "" echo "▶ Installation du service systemd..." cp "$INSTALL_DIR/systemd/jh-photomaton.service" /etc/systemd/system/ systemctl daemon-reload systemctl enable jh-photomaton.service echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo " ✅ Installation terminée !" echo "" echo " Fichiers : $INSTALL_DIR" echo " Config : $INSTALL_DIR/config/settings.yaml" echo "" echo " ▶ Démarrer le service :" echo " sudo systemctl start jh-photomaton" echo "" echo " ▶ Voir les logs :" echo " sudo journalctl -u jh-photomaton -f" echo "" echo " ▶ Interface admin :" echo " http://:8090/admin" echo " Mot de passe : PhotoBooth2026!" echo "" echo " ⚠️ Penser à mettre à jour plugin_commander.json" echo " dans photobooth-app pour pointer vers notre webhook !" echo " Voir : config/plugin_commander_jh.json" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"