cam: go2rtc + mic-bridge

This commit is contained in:
2026-10-22 02:27:01 +02:00
commit 831e4b0ae0
10 changed files with 438 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
* * * * * root /usr/local/bin/cam-watch
+34
View File
@@ -0,0 +1,34 @@
#!/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/cam && docker compose up -d --force-recreate 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}}' 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