first commit
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
#!/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
|
||||
|
||||
"$VENV_DIR/bin/pip" install --upgrade pip -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://<ip-du-pi>: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 "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Démarrage de JH Photomaton
|
||||
INSTALL_DIR="/home/pi/jh-photomaton"
|
||||
VENV="$INSTALL_DIR/.venv/bin/python"
|
||||
|
||||
cd "$INSTALL_DIR"
|
||||
exec "$VENV" main.py
|
||||
@@ -0,0 +1,17 @@
|
||||
# =============================================================================
|
||||
# Règle sudoers — JH Photomaton
|
||||
#
|
||||
# INSTALLATION :
|
||||
# sudo cp scripts/sudoers-jh-photomaton /etc/sudoers.d/jh-photomaton
|
||||
# sudo chmod 440 /etc/sudoers.d/jh-photomaton
|
||||
# sudo visudo -c # vérification syntaxe
|
||||
#
|
||||
# Permet à l'utilisateur 'pi' de redémarrer/vérifier le service jh-photomaton
|
||||
# sans saisir de mot de passe sudo — requis pour le déploiement CI/CD.
|
||||
# =============================================================================
|
||||
|
||||
pi ALL=(ALL) NOPASSWD: /bin/systemctl restart jh-photomaton, \
|
||||
/bin/systemctl start jh-photomaton, \
|
||||
/bin/systemctl stop jh-photomaton, \
|
||||
/bin/systemctl status jh-photomaton, \
|
||||
/bin/systemctl reload jh-photomaton
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# JH Photomaton — Script de mise à jour
|
||||
# Appelé par le CI/CD Gitea Actions (deploy.yml)
|
||||
# Peut aussi être exécuté manuellement : bash scripts/update.sh
|
||||
# =============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_DIR="/home/pi/jh-photomaton"
|
||||
VENV="$INSTALL_DIR/.venv/bin/pip"
|
||||
|
||||
echo "▶ Mise à jour du code source..."
|
||||
cd "$INSTALL_DIR"
|
||||
|
||||
# Sauvegarder les modifications locales (ex: settings.yaml personnalisé)
|
||||
# git stash ne fail pas si rien à stasher
|
||||
git stash push --include-untracked --message "auto-stash avant deploy $(date +%Y%m%d-%H%M%S)" 2>/dev/null || true
|
||||
|
||||
# Pull depuis origin/main
|
||||
git pull origin main
|
||||
|
||||
# Réappliquer les modifs locales (settings.yaml, etc.)
|
||||
# Si conflit → les fichiers locaux prennent le dessus
|
||||
git stash pop 2>/dev/null || true
|
||||
|
||||
echo "▶ Mise à jour des dépendances Python..."
|
||||
"$VENV" install -r "$INSTALL_DIR/requirements.txt" -q
|
||||
|
||||
echo "▶ Redémarrage du service..."
|
||||
sudo /bin/systemctl restart jh-photomaton
|
||||
|
||||
# Attendre que le service soit UP
|
||||
sleep 2
|
||||
sudo /bin/systemctl status jh-photomaton --no-pager -l
|
||||
|
||||
echo ""
|
||||
echo "✅ JH Photomaton mis à jour et redémarré."
|
||||
echo " Logs : sudo journalctl -u jh-photomaton -f"
|
||||
Reference in New Issue
Block a user