Files
AI-Profile-Router/platform/ltx2-studio/entrypoint.sh
T

43 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
set -eu
install -d -m 0755 "$HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" /data/models /data/outputs
cleanup() {
kill "${app_pid:-}" "${web_pid:-}" "${vnc_pid:-}" "${wm_pid:-}" "${x_pid:-}" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
# A stopped container keeps its writable layer. Remove stale X11 state so the
# same container can be started again by the profile controller.
rm -f /tmp/.X0-lock /tmp/.X11-unix/X0
# Keep Chromium session data ephemeral. LTX models, settings, authentication and
# outputs remain in /data/LTXDesktop through XDG_DATA_HOME.
rm -rf /tmp/ltx-electron-profile
# Electron keeps its single-instance markers in the persistent LTX data path.
# They point at the stopped container and must not survive a profile switch.
rm -f /data/LTXDesktop/SingletonCookie /data/LTXDesktop/SingletonLock /data/LTXDesktop/SingletonSocket
Xvfb :0 -screen 0 1600x1000x24 -nolisten tcp &
x_pid=$!
for _ in $(seq 1 50); do
[ -S /tmp/.X11-unix/X0 ] && break
sleep 0.1
done
openbox >/tmp/openbox.log 2>&1 &
wm_pid=$!
x11vnc -display :0 -forever -shared -nopw -rfbport 5900 \
>/tmp/x11vnc.log 2>&1 &
vnc_pid=$!
websockify --web=/usr/share/novnc 8015 127.0.0.1:5900 \
>/tmp/websockify.log 2>&1 &
web_pid=$!
export APPDIR=/opt/ltx-desktop/squashfs-root
cd "$APPDIR"
./AppRun --no-sandbox --disable-gpu-sandbox \
--disable-dev-shm-usage --user-data-dir=/tmp/ltx-electron-profile >/data/ltx-desktop.log 2>&1 &
app_pid=$!
wait "$app_pid"