#!/bin/sh set -eu Xvfb :99 -screen 0 "${SCREEN_SIZE:-1920x1080x24}" -nolisten tcp -ac & xvfb_pid=$! i=0 while [ "$i" -lt 300 ]; do [ -S /tmp/.X11-unix/X99 ] && break kill -0 "$xvfb_pid" 2>/dev/null || exit 1 i=$((i + 1)) sleep 0.1 done [ -S /tmp/.X11-unix/X99 ] || { echo "Xvfb did not become ready" >&2 exit 1 } export DISPLAY=:99 x11vnc -display :99 -listen "$(hostname -i)" -rfbport 5900 -forever -nopw -nevershared -dontdisconnect -noclipboard -nosetclipboard -noprimary -nosetprimary -quiet & rfb_pid=$! kill -0 "$rfb_pid" 2>/dev/null || { echo "RFB service did not start" >&2 exit 1 } remote_debugging_port=${REMOTE_DEBUGGING_PORT:-9222} case "$remote_debugging_port" in '' | *[!0-9]*) echo "REMOTE_DEBUGGING_PORT must be numeric" >&2 exit 2 ;; esac socat "TCP-LISTEN:${remote_debugging_port},fork,reuseaddr,bind=$(hostname -i)" "TCP:127.0.0.1:${remote_debugging_port}" & exec /opt/chromium/chrome --disable-dev-shm-usage --no-sandbox --no-default-browser-check --no-first-run --remote-debugging-port="$remote_debugging_port" --user-data-dir=/data "$@"