#!/bin/bash set -e VNC_PASSWORD="${VNC_PASSWORD:-changeme}" RESOLUTION="${RESOLUTION:-1280x800}" if [ "$VNC_PASSWORD" = "changeme" ]; then echo "WARNING: using default VNC password 'changeme'. Set VNC_PASSWORD in your .env file." >&2 fi # This tigervnc build ships no vncpasswd tool; it authenticates VNC's "Plain" # security type against the Unix account password via PAM instead. echo "ubuntu:${VNC_PASSWORD}" | sudo chpasswd mkdir -p "$HOME/.vnc" cp /opt/vnc/xstartup "$HOME/.vnc/xstartup" chmod +x "$HOME/.vnc/xstartup" # Clean up any stale lock/pid files from a previous run of this volume vncserver -kill :1 >/dev/null 2>&1 || true rm -f /tmp/.X1-lock /tmp/.X11-unix/X1 vncserver :1 -geometry "$RESOLUTION" -depth 24 -localhost no \ -SecurityTypes Plain -PlainUsers ubuntu websockify --web=/usr/share/novnc/ 6901 localhost:5901 & LOGFILE="$HOME/.vnc/$(hostname):1.log" touch "$LOGFILE" exec tail -f "$LOGFILE"