The desktop page has never worked on a fresh install. Two faults, both fatal.
The password could never be created. DesktopView fetches /desktop/vnc-password
before opening the WebSocket, but ensureVncPassword ran only from startSession,
which only the WebSocket triggers — so the endpoint answered "not configured",
the UI stopped, and the socket that would have provisioned it was never opened.
A new vnc:ensure-password sidecar command provisions it directly; the endpoint
asks for it instead of returning 500.
The rfbauth file could never be written either. ensureVncPassword shelled out to
tigervnc's `vncpasswd -f`, which is not installed — and, contrary to the comment
in setup-desktop.sh, is not in tigervnc-common, which ships only tigervncconfig.
The failure was swallowed because only a zero exit wrote the file, so x11vnc got
-rfbauth pointing at nothing. x11vnc writes that format itself with -storepasswd,
so the dependency is gone and a failure now throws.
Verified on the box: the endpoint returns a password, .vnc/{passwd,password} are
written 0600, and the sidecar reports mirroring :0 on 5900 with x11vnc using the
generated rfbauth file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
108 lines
4.8 KiB
Bash
Executable File
108 lines
4.8 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Officer Remote Desktop Setup — Ubuntu GNOME desktop on Xorg, mirrored over VNC.
|
|
#
|
|
# The platform mirrors the single physical display :0 with x11vnc (see vnc-manager.ts). x11vnc can only
|
|
# capture an Xorg server, NOT a Wayland compositor — so we install the full GNOME desktop but force GDM
|
|
# onto the Xorg session (WaylandEnable=false). Auto-login is enabled so a user session owns :0 for the
|
|
# mirror to attach to. Switching the display manager takes effect on the next reboot.
|
|
# Usage: ./scripts/setup-desktop.sh
|
|
|
|
echo "=== Officer Remote Desktop Setup (Ubuntu GNOME on Xorg) ==="
|
|
echo ""
|
|
|
|
DESKTOP_USER="$(whoami)"
|
|
|
|
# --- Step 1: Install GNOME desktop + GDM + x11vnc ---
|
|
echo "[1/5] Installing ubuntu-desktop, GDM, x11vnc..."
|
|
sudo apt update -qq
|
|
sudo DEBIAN_FRONTEND=noninteractive apt install -y -qq \
|
|
ubuntu-desktop \
|
|
gdm3 \
|
|
x11vnc \
|
|
dbus-x11
|
|
echo " Done."
|
|
# No tigervnc package is needed. The VNC sidecar writes the .vnc/passwd rfbauth file with
|
|
# `x11vnc -storepasswd` (see vnc-manager.ts). tigervnc-common was installed here for `vncpasswd`,
|
|
# but it does not ship that binary — it only provides tigervncconfig — so the rfbauth file was never
|
|
# created and the desktop could not authenticate.
|
|
|
|
# --- Step 2: Force GDM onto Xorg + enable auto-login (x11vnc cannot mirror Wayland) ---
|
|
echo "[2/5] Forcing Xorg session and auto-login in GDM..."
|
|
GDM_CONF=/etc/gdm3/custom.conf
|
|
sudo mkdir -p /etc/gdm3
|
|
[ -f "$GDM_CONF" ] || echo "[daemon]" | sudo tee "$GDM_CONF" > /dev/null
|
|
# Ensure a [daemon] section exists to anchor the keys under.
|
|
sudo grep -qE '^\[daemon\]' "$GDM_CONF" || echo "[daemon]" | sudo tee -a "$GDM_CONF" > /dev/null
|
|
|
|
# Set key=value under [daemon]: rewrite an existing (possibly commented) line, else insert after [daemon].
|
|
set_gdm_key() {
|
|
local key="$1" val="$2"
|
|
if sudo grep -qE "^[[:space:]]*#?[[:space:]]*${key}=" "$GDM_CONF"; then
|
|
sudo sed -i "s|^[[:space:]]*#\?[[:space:]]*${key}=.*|${key}=${val}|" "$GDM_CONF"
|
|
else
|
|
sudo sed -i "/^\[daemon\]/a ${key}=${val}" "$GDM_CONF"
|
|
fi
|
|
}
|
|
|
|
set_gdm_key WaylandEnable false
|
|
set_gdm_key AutomaticLoginEnable true
|
|
set_gdm_key AutomaticLogin "$DESKTOP_USER"
|
|
echo " Xorg forced (WaylandEnable=false), auto-login as $DESKTOP_USER."
|
|
|
|
# --- Step 3: Make GDM the default display manager ---
|
|
echo "[3/5] Setting GDM as the default display manager..."
|
|
echo "/usr/sbin/gdm3" | sudo tee /etc/X11/default-display-manager > /dev/null
|
|
sudo systemctl enable gdm3 >/dev/null 2>&1 || sudo systemctl enable gdm >/dev/null 2>&1 || true
|
|
sudo systemctl set-default graphical.target >/dev/null 2>&1 || true
|
|
# Disable any prior display manager (e.g. lightdm from an XFCE setup) so it doesn't fight GDM.
|
|
sudo systemctl disable lightdm >/dev/null 2>&1 || true
|
|
echo " Done (takes effect on next reboot)."
|
|
|
|
# --- Step 4: Install Brave browser (native .deb, not snap) ---
|
|
echo "[4/5] Installing Brave browser..."
|
|
if ! command -v brave-browser-stable > /dev/null 2>&1; then
|
|
sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg \
|
|
https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
|
|
echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" \
|
|
| sudo tee /etc/apt/sources.list.d/brave-browser-release.list > /dev/null
|
|
sudo apt update -qq
|
|
sudo DEBIAN_FRONTEND=noninteractive apt install -y -qq brave-browser
|
|
fi
|
|
# Fix launcher symlink
|
|
if [ -f /opt/brave.com/brave/brave-browser ]; then
|
|
sudo rm -f /usr/bin/brave-browser-stable
|
|
sudo ln -s /opt/brave.com/brave/brave-browser /usr/bin/brave-browser-stable
|
|
fi
|
|
# Tell Brave to use basic password store (no keyring prompts)
|
|
sudo mkdir -p /etc/brave
|
|
echo '--password-store=basic' | sudo tee /etc/brave/brave-flags.conf > /dev/null
|
|
echo " Done."
|
|
|
|
# --- Step 5: Remove GNOME Keyring + set default browser (prevents password prompts on login) ---
|
|
echo "[5/5] Removing GNOME Keyring and setting default browser..."
|
|
sudo apt remove -y --purge gnome-keyring > /dev/null 2>&1 || true
|
|
rm -rf ~/.local/share/keyrings
|
|
if command -v brave-browser-stable > /dev/null 2>&1; then
|
|
sudo update-alternatives --set x-www-browser /opt/brave.com/brave/brave 2>/dev/null || true
|
|
echo " Brave set as default."
|
|
else
|
|
echo " No supported browser found, skipping default."
|
|
fi
|
|
|
|
# --- Cleanup old systemd service if it exists ---
|
|
if systemctl list-unit-files officer-vnc.service &>/dev/null; then
|
|
echo ""
|
|
echo "Removing old officer-vnc systemd service..."
|
|
sudo systemctl stop officer-vnc 2>/dev/null || true
|
|
sudo systemctl disable officer-vnc 2>/dev/null || true
|
|
sudo rm -f /etc/systemd/system/officer-vnc.service
|
|
sudo systemctl daemon-reload
|
|
echo " Done."
|
|
fi
|
|
|
|
echo ""
|
|
echo "Setup complete. The screen mirror (x11vnc on :0) is managed by the VNC sidecar."
|
|
echo "REBOOT to switch into the GNOME-on-Xorg session with auto-login."
|