Files
baiyue-firstleg/deploy/docker/lingxing-browser/entrypoint.sh
T
2026-09-23 08:58:56 +08:00

39 lines
1.5 KiB
Bash

#!/bin/sh
set -eu
mkdir -p "$PROFILE_DIR" /tmp/lingxing-runtime /tmp/.X11-unix
rm -f /tmp/.X99-lock /tmp/.X11-unix/X99
rm -f "$PROFILE_DIR/SingletonCookie" "$PROFILE_DIR/SingletonLock" "$PROFILE_DIR/SingletonSocket"
chmod 1777 /tmp/.X11-unix
chown -R browser:browser "$PROFILE_DIR" /tmp/lingxing-runtime
chmod 0700 "$PROFILE_DIR" /tmp/lingxing-runtime
cleanup() {
for pid in "${CHROMIUM_PID:-}" "${CDP_PROXY_PID:-}" "${NOVNC_PID:-}" "${VNC_PID:-}" "${OPENBOX_PID:-}" "${XVFB_PID:-}"; do
[ -n "$pid" ] && kill "$pid" 2>/dev/null || true
done
}
trap cleanup EXIT INT TERM
su-exec browser Xvfb "$DISPLAY" -screen 0 1440x900x24 -nolisten tcp & XVFB_PID=$!
sleep 1
su-exec browser env DISPLAY="$DISPLAY" XDG_RUNTIME_DIR=/tmp/lingxing-runtime openbox & OPENBOX_PID=$!
su-exec browser x0vncserver -display "$DISPLAY" -localhost -rfbport 5900 -SecurityTypes None -AlwaysShared & VNC_PID=$!
su-exec browser websockify --web=/usr/share/novnc 0.0.0.0:6080 127.0.0.1:5900 & NOVNC_PID=$!
su-exec browser socat TCP-LISTEN:9222,bind=0.0.0.0,reuseaddr,fork TCP:127.0.0.1:9223 & CDP_PROXY_PID=$!
su-exec browser env DISPLAY="$DISPLAY" XDG_RUNTIME_DIR=/tmp/lingxing-runtime chromium-browser \
--user-data-dir="$PROFILE_DIR" \
--remote-debugging-address=0.0.0.0 \
--remote-debugging-port=9223 \
--window-size=1440,900 \
--disable-gpu \
--use-gl=swiftshader \
--disable-dev-shm-usage \
--no-first-run \
--no-default-browser-check \
--no-sandbox \
"$LINGXING_LOGIN_URL" & CHROMIUM_PID=$!
wait "$CHROMIUM_PID"