Spaces:
Paused
Paused
| set -euo pipefail | |
| echo "==== Starting LXDE + Firefox + noVNC + cloudflared ====" | |
| # عرض الإعدادات | |
| echo "DISPLAY=${DISPLAY}" | |
| echo "VNC password file=/root/.vnc/passwd" | |
| echo "Resolution=${GEOMETRY}" | |
| echo "noVNC port=${NOVNC_PORT}" | |
| export DISPLAY=:1 | |
| # تشغيل الشاشة الوهمية Xvfb | |
| Xvfb :1 -screen 0 ${GEOMETRY}x16 2>&1 | tee /proc/1/fd/1 & | |
| XVFB_PID=$! | |
| echo "Started Xvfb (PID $XVFB_PID)" | |
| # تشغيل dbus | |
| if ! pgrep -x dbus-daemon >/dev/null 2>&1; then | |
| dbus-daemon --session --fork --print-address > /tmp/dbus_address || true | |
| echo "Started dbus-daemon" | |
| fi | |
| # تشغيل Firefox | |
| firefox 2>&1 | tee /proc/1/fd/1 & | |
| FIREFOX_PID=$! | |
| echo "Started Firefox (PID $FIREFOX_PID)" | |
| # تشغيل x11vnc مع كلمة مرور | |
| x11vnc -display :1 -forever -usepw -shared 2>&1 | tee /proc/1/fd/1 & | |
| X11VNC_PID=$! | |
| echo "Started x11vnc (PID $X11VNC_PID)" | |
| # تشغيل noVNC proxy | |
| python3 /opt/novnc/utils/novnc_proxy --vnc localhost:5900 --listen ${NOVNC_PORT} 2>&1 | tee /proc/1/fd/1 & | |
| NOVNC_PID=$! | |
| echo "Started noVNC (PID $NOVNC_PID) at http://localhost:${NOVNC_PORT}/vnc.html" | |
| # تشغيل cloudflared مع إعادة التشغيل التلقائية | |
| restart_cloudflared() { | |
| while true; do | |
| echo "Starting cloudflared tunnel..." | |
| cloudflared tunnel --url http://localhost:${NOVNC_PORT} --no-autoupdate 2>&1 | tee /proc/1/fd/1 | |
| echo "cloudflared crashed. Restarting in 5 seconds..." | |
| sleep 5 | |
| done | |
| } | |
| restart_cloudflared & | |
| # إبقاء الحاوية تعمل للأبد (يمكن الاحتفاظ بها) | |
| tail -f /dev/null |