#!/bin/bash # 1. Set the VNC password (optional, defaults to 'password') export VNC_PASSWD=${VNC_PASSWD:-password} # 2. Start the Virtual Framebuffer (The fake monitor) # 1280x720 is a safe resolution for browser windows Xvfb :1 -screen 0 1280x720x16 & export DISPLAY=:1 sleep 2 # 3. Start the Window Manager (XFCE) startxfce4 & sleep 2 # 4. Start the VNC Server (Connects to the display) # We store the password in a file for x11vnc to use mkdir -p ~/.vnc x11vnc -storepasswd "$VNC_PASSWD" ~/.vnc/passwd x11vnc -display :1 -rfbauth ~/.vnc/passwd -forever -shared -bg # 5. Start NoVNC (The Web Interface) # This proxies the VNC data to the HTTP port 7860 # We verify the location of websockify (it varies by distro, this finds it) WEBSOCKIFY_PATH=$(which websockify 2>/dev/null || echo "/usr/lib/novnc/utils/websockify") echo "Starting NoVNC on port 7860..." # Use the python implementation of websockify to bridge the gap /usr/share/novnc/utils/launch.sh --vnc localhost:5900 --listen 7860