#!/usr/bin/env bash set -euo pipefail IDLE_TIMEOUT="${IDLE_TIMEOUT:-1800}" X11VNC_FLAGS="${X11VNC_FLAGS:--wait 5 -defer 5 -threads}" SCREEN_GEOMETRY="${SCREEN_GEOMETRY:-1920x1080x24}" CHROME_WINDOW_SIZE="${CHROME_WINDOW_SIZE:-1920,1080}" ENABLE_HEARTBEAT="${ENABLE_HEARTBEAT:-1}" DISPLAY_NUM="${DISPLAY_NUM:-:1}" mkdir -p /opt/portal cp -r /usr/share/novnc/* /opt/portal/ cat > /opt/portal/index.html <<'HTML' Universal Session
Подключение к слоту...
HTML export DISPLAY="$DISPLAY_NUM" export CHROME_WINDOW_SIZE Xvfb "$DISPLAY_NUM" -screen 0 "$SCREEN_GEOMETRY" >/tmp/xvfb.log 2>&1 & fluxbox >/tmp/fluxbox.log 2>&1 & python3 /manager.py >/tmp/manager.log 2>&1 & start_x11vnc_with_retry() { local display_arg="$1" local attempt=0 while [ "$attempt" -lt 12 ]; do x11vnc -display "$display_arg" -rfbport 5900 -forever -shared -nopw -noxdamage $X11VNC_FLAGS >/tmp/x11vnc.log 2>&1 & local pid=$! sleep 1 if kill -0 "$pid" 2>/dev/null; then return 0 fi attempt=$((attempt + 1)) sleep 0.5 done return 1 } start_x11vnc_with_retry "$DISPLAY_NUM" || true exec websockify --verbose --idle-timeout="$IDLE_TIMEOUT" --web=/opt/portal 6080 localhost:5900