Files
photobooth/scripts/kiosk-session.sh
Jules 5a81907a0e Kiosk : flag maintenance + anti-doublon backend
- Check /tmp/photobooth-maintenance pour bloquer le restart loop
- Vérifie qu'aucun backend ne tourne avant d'en lancer un nouveau

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-26 19:49:51 +02:00

77 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Verrou : une seule instance autorisée
LOCK=/tmp/photobooth-kiosk.lock
if [ -f "$LOCK" ] && kill -0 "$(cat $LOCK)" 2>/dev/null; then
echo "[kiosk] Déjà en cours (pid $(cat $LOCK)), abandon."
exit 0
fi
echo $$ > "$LOCK"
trap "rm -f $LOCK" EXIT
xset s off
xset -dpms
xset s noblank
# Automount USB (pour la photostation)
udiskie --no-notify --no-appindicator &
# Libérer le DSLR : gvfsd-gphoto2 (GNOME) le monopolise sinon
pkill -f gvfsd-gphoto2 2>/dev/null || true
pkill -f gvfs-gphoto2-volume-monitor 2>/dev/null || true
sleep 1
# Backend en boucle : redémarre automatiquement s'il plante
_backend_loop() {
while true; do
# Mode maintenance : attendre la fin de l'intervention
while [ -f /tmp/photobooth-maintenance ]; do sleep 2; done
# Vérifier qu'aucun autre backend ne tourne (éviter les doublons)
if pgrep -f "python.*backend.main" > /dev/null 2>&1; then
echo "[kiosk] backend déjà en cours, attente..."
sleep 5
continue
fi
cd /home/jules/photobooth
# Mise à jour automatique depuis Gitea
git pull --ff-only 2>&1 | logger -t photobooth-git
source .venv/bin/activate
authbind --deep python -m backend.main 2>&1 | tee -a /tmp/photobooth-backend.log
echo "[kiosk] backend terminé, redémarrage dans 3s..."
sleep 3
done
}
_backend_loop &
# Attendre que le backend soit prêt (max 15s)
for i in $(seq 1 15); do
curl -sf http://localhost/ > /dev/null 2>&1 && break
sleep 1
done
# Chromium en boucle : redémarre s'il plante, attend si photostation active
while true; do
while [ -f /tmp/photostation_running ]; do sleep 1; done
chromium \
--kiosk \
--noerrdialogs \
--disable-infobars \
--disable-translate \
--disable-features=TranslateUI,Translate,LockProfileCookieDatabase \
--disable-session-crashed-bubble \
--disable-component-update \
--check-for-update-interval=31536000 \
--autoplay-policy=no-user-gesture-required \
--start-fullscreen \
--user-data-dir=/home/jules/.config/chromium-kiosk \
--touch-events=enabled \
--enable-touch-drag-drop \
--force-device-scale-factor=3 \
--password-store=basic \
--lang=fr \
--remote-debugging-port=9222 \
http://localhost
echo "[kiosk] Chromium terminé, redémarrage dans 2s..."
sleep 2
done