Migrate to Chromium, unified VNC, thumbnails, autologin CDP detection
--- - Migrado base Docker de ubuntu:22.04 + Google Chrome para debian:bookworm-slim + Chromium - Dockerfile refatorado com multi-stage build (node:22-alpine builder + debian runtime) e single RUN layer para imagem menor - VNC unificado: removido novnc por stream, substituído por websockify global na porta 6080 com token-based routing - Implementado sistema de thumbnails por stream via ffmpeg (captura do HLS) com endpoint GET/POST e atualização no card - Autologin reescrito com detecção via Chrome DevTools Protocol: pula credenciais se já autenticado - Adicionado padrão desiredState (running/stopped) persistido no JSON, restaurado via restore-streams.sh ao reiniciar container - UI traduzida para inglês, formulário reorganizado com tooltips, seção avançada colapsável e GOP automático - Player simplificado: modos HLS e HTML unificados, removido modo m3u8 separado - Adicionado campo threads no ffmpeg; suporte a seccomp:unconfined no docker-compose ---
This commit is contained in:
@@ -1,11 +1,37 @@
|
||||
#!/bin/bash
|
||||
# Gerado automaticamente pela API — não editar manualmente
|
||||
# Auto-generated by API — do not edit manually
|
||||
# Stream: {{STREAM_ID}}
|
||||
|
||||
[ -z "{{USER}}" ] && exit 0
|
||||
|
||||
sleep {{STREAM_DELAY}}
|
||||
|
||||
# Query Chrome DevTools Protocol to detect current page URL
|
||||
CURRENT_URL=$(node -e "
|
||||
const http = require('http');
|
||||
http.get('http://localhost:{{DEBUG_PORT}}/json', res => {
|
||||
let d = '';
|
||||
res.on('data', c => d += c);
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const tabs = JSON.parse(d);
|
||||
const page = tabs.find(t => t.type === 'page');
|
||||
process.stdout.write(page ? page.url : '');
|
||||
} catch { process.stdout.write(''); }
|
||||
});
|
||||
}).on('error', () => process.stdout.write(''));
|
||||
" 2>/dev/null)
|
||||
|
||||
# If we got a URL and it doesn't look like a login page, skip autologin
|
||||
if [ -n "$CURRENT_URL" ] && ! echo "$CURRENT_URL" | grep -qiE '/(login|signin|sign-in|auth|sso|oauth)'; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DISPLAY={{DISPLAY}} xdotool search --sync --onlyvisible --class chromium windowfocus windowraise
|
||||
sleep 1
|
||||
|
||||
DISPLAY={{DISPLAY}} xdotool type --clearmodifiers --delay 50 "{{USER}}"
|
||||
DISPLAY={{DISPLAY}} xdotool key Tab
|
||||
sleep 0.3
|
||||
DISPLAY={{DISPLAY}} xdotool type --clearmodifiers --delay 50 "{{PASS}}"
|
||||
DISPLAY={{DISPLAY}} xdotool key Return
|
||||
sleep 3
|
||||
DISPLAY={{DISPLAY}} xdotool key F11
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
# #19 — aguarda supervisord e restaura streams para o desiredState salvo
|
||||
sleep 5
|
||||
|
||||
STREAMS_FILE="/app/data/streams.json"
|
||||
[ -f "$STREAMS_FILE" ] || exit 0
|
||||
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const { execSync } = require('child_process');
|
||||
const streams = JSON.parse(fs.readFileSync('$STREAMS_FILE', 'utf-8'));
|
||||
const ctl = (cmd) => { try { execSync('supervisorctl -c /etc/supervisor/supervisord.conf ' + cmd, { stdio: 'pipe' }); } catch {} };
|
||||
|
||||
for (const s of streams) {
|
||||
if (s.desiredState === 'running') {
|
||||
console.log('[restore] starting', s.id);
|
||||
['xvfb','chromium','autologin','x11vnc','ffmpeg'].forEach(p => ctl('start ' + p + '-' + s.id));
|
||||
} else {
|
||||
console.log('[restore] keeping stopped', s.id);
|
||||
}
|
||||
}
|
||||
"
|
||||
@@ -8,29 +8,32 @@ priority=10
|
||||
stdout_logfile=/app/data/streams/{{STREAM_ID}}/xvfb.log
|
||||
stderr_logfile=/app/data/streams/{{STREAM_ID}}/xvfb.log
|
||||
|
||||
[program:chrome-{{STREAM_ID}}]
|
||||
command=bash -c "rm -rf /app/data/streams/{{STREAM_ID}}/chrome-profile/Singleton* && google-chrome \
|
||||
[program:chromium-{{STREAM_ID}}]
|
||||
command=bash -c "rm -rf \
|
||||
/app/data/streams/{{STREAM_ID}}/chrome-profile/Singleton* \
|
||||
/app/data/streams/{{STREAM_ID}}/chrome-profile/.org.chromium.* \
|
||||
'/app/data/streams/{{STREAM_ID}}/chrome-profile/Default/Crash Reports' \
|
||||
/app/data/streams/{{STREAM_ID}}/chrome-profile/Default/.org.chromium.* \
|
||||
&& chromium \
|
||||
--no-sandbox \
|
||||
--disable-gpu \
|
||||
--window-size={{RESOLUTION}} \
|
||||
--start-maximized \
|
||||
--user-data-dir=/app/data/streams/{{STREAM_ID}}/chrome-profile \
|
||||
--test-type \
|
||||
--disable-infobars \
|
||||
--disable-gpu \
|
||||
--window-size={{CHROME_SIZE}} \
|
||||
--start-fullscreen \
|
||||
--user-data-dir=/app/data/streams/{{STREAM_ID}}/chrome-profile \
|
||||
--no-first-run \
|
||||
--disable-extensions \
|
||||
--disable-background-networking \
|
||||
--disable-sync \
|
||||
--disable-translate \
|
||||
--disable-background-timer-throttling \
|
||||
--remote-debugging-port={{DEBUG_PORT}} \
|
||||
"{{STREAM_URL}}""
|
||||
'{{STREAM_URL}}'"
|
||||
environment=DISPLAY={{DISPLAY}}
|
||||
autorestart=true
|
||||
priority=20
|
||||
startsecs=5
|
||||
stdout_logfile=/app/data/streams/{{STREAM_ID}}/chrome.log
|
||||
stderr_logfile=/app/data/streams/{{STREAM_ID}}/chrome.log
|
||||
stdout_logfile=/app/data/streams/{{STREAM_ID}}/chromium.log
|
||||
stderr_logfile=/app/data/streams/{{STREAM_ID}}/chromium.log
|
||||
|
||||
[program:autologin-{{STREAM_ID}}]
|
||||
command=/app/data/streams/{{STREAM_ID}}/autologin.sh
|
||||
@@ -43,22 +46,16 @@ stderr_logfile=/app/data/streams/{{STREAM_ID}}/autologin.log
|
||||
|
||||
[program:x11vnc-{{STREAM_ID}}]
|
||||
environment=DISPLAY={{DISPLAY}}
|
||||
command=bash -c "while [ ! -e /tmp/.X11-unix/X$(echo $DISPLAY | cut -d: -f2 | cut -d. -f1) ]; do sleep 0.2; done; exec x11vnc -nopw -listen 0.0.0.0 -rfbport {{VNC_PORT}} -xkb -forever -shared"
|
||||
command=bash -c "while [ ! -e /tmp/.X11-unix/X$(echo $DISPLAY | cut -d: -f2 | cut -d. -f1) ]; do sleep 0.2; done; exec x11vnc -nopw -listen 0.0.0.0 -rfbport {{VNC_PORT}} -xkb -forever -shared -threads"
|
||||
autorestart=true
|
||||
priority=40
|
||||
stdout_logfile=/app/data/streams/{{STREAM_ID}}/vnc.log
|
||||
stderr_logfile=/app/data/streams/{{STREAM_ID}}/vnc.log
|
||||
|
||||
[program:novnc-{{STREAM_ID}}]
|
||||
command=websockify --web /usr/share/novnc {{NOVNC_PORT}} localhost:{{VNC_PORT}}
|
||||
autorestart=true
|
||||
priority=50
|
||||
stdout_logfile=/app/data/streams/{{STREAM_ID}}/novnc.log
|
||||
stderr_logfile=/app/data/streams/{{STREAM_ID}}/novnc.log
|
||||
|
||||
[program:ffmpeg-{{STREAM_ID}}]
|
||||
command=bash -c "sleep {{STREAM_DELAY}} && ffmpeg \
|
||||
-loglevel warning \
|
||||
-threads {{THREADS}} \
|
||||
-f x11grab \
|
||||
-video_size {{RESOLUTION}} \
|
||||
-framerate {{FPS}} \
|
||||
|
||||
Reference in New Issue
Block a user