Files
Kai-Sa-Cam/scripts/cam-watch.sh
T
Esiah c6b08b4812
CD — Kai-Sa-Cam Deployment / deploy (push) Successful in 1m59s
feat: handle Cloudflare Access session expiry and serve go2rtc same-origin
- add apiFetch wrapper with re-auth popup, retry and session monitor
- proxy go2rtc through the app (/go2rtc) and drop the public stream hostname
- route WebSocket upgrades manually (the talk WSS was rejecting go2rtc MSE)
- harden talkback: paplay error handling, heartbeat, single speaker, reconnect
- sync recording state with the server on load and on 409
- optionally verify Cf-Access-Jwt-Assertion (CF_ACCESS_TEAM_DOMAIN/AUD)
- keep go2rtc on the internal network only
- remove unused env vars, update README and cam-watch script
2026-10-26 00:50:08 +01:00

35 lines
1.0 KiB
Bash

#!/bin/bash
LOG=/var/log/cam-watch.log
STAMP=/run/cam-watch.last
STATE=/run/cam-watch.state
COOLDOWN=120
now=$(date +%s)
last=$(cat "$STAMP" 2>/dev/null || echo 0)
[ $((now - last)) -lt $COOLDOWN ] && exit 0
recreate() {
echo "$(date '+%F %T') $1 : recreation go2rtc" >> "$LOG"
(cd /srv/apps/kai-sa-cam && docker compose --profile prod up -d --force-recreate kai-sa-go2rtc >/dev/null 2>&1)
echo "$now" > "$STAMP"
}
prev=$(cat "$STATE" 2>/dev/null || echo ok)
# Webcam reellement presente ? (lsusb plus fiable que /dev/video0 qui peut etre perime)
if lsusb | grep -q '1d5b:0104'; then
if [ "$prev" = "absent" ]; then
echo "$(date '+%F %T') webcam revenue" >> "$LOG"
echo "ok" > "$STATE"
sleep 5
recreate "retour webcam"
exit 0
fi
echo "ok" > "$STATE"
if [ "$(docker inspect -f '{{.State.Running}}' kai-sa-go2rtc 2>/dev/null)" != "true" ]; then
recreate "go2rtc arrete"
fi
else
[ "$prev" != "absent" ] && echo "$(date '+%F %T') webcam ABSENTE (probleme USB)" >> "$LOG"
echo "absent" > "$STATE"
fi