diff --git a/setup-vnc.sh b/setup-vnc.sh new file mode 100755 index 0000000..5741a1a --- /dev/null +++ b/setup-vnc.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Setup VNC server for headless Obsidian access + +set -e + +echo "📺 Setting up VNC server for Obsidian GUI access..." + +# Install x11vnc (exports existing X display) +echo "Installing x11vnc..." +sudo apt-get update -qq +sudo apt-get install -y -qq x11vnc + +# Since Obsidian runs on :99 via Xvfb, we'll use :100 for VNC and point it to the same display +# Or better: use x11vnc to export the existing :99 display + +echo "Installing x11vnc (exports existing X display)..." +sudo apt-get install -y -qq x11vnc + +# Create systemd service for VNC +sudo tee /etc/systemd/system/vncserver.service > /dev/null << 'EOF' +[Unit] +Description=VNC Server for Xvfb Display :99 +After=obsidian.service +Requires=obsidian.service + +[Service] +Type=simple +User=intense +Environment="DISPLAY=:99" +ExecStart=/usr/bin/x11vnc -display :99 -forever -nopw -listen localhost +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF + +# Enable and start VNC +sudo systemctl daemon-reload +sudo systemctl enable vncserver.service +sudo systemctl start vncserver.service + +echo "✅ VNC server installed!" +echo "" +echo "Starting VNC service..." +sudo systemctl start vncserver.service +sleep 2 +sudo systemctl status vncserver.service || true +echo "" +echo "📺 Connect from your local machine:" +echo "" +echo " 1. Open VNC client (TightVNC, RealVNC, VNCViewer, etc.)" +echo " 2. Connect to: localhost:5900" +echo " (or IP_OF_SERVER:5900 if remote)" +echo " 3. No password required (nopw mode)" +echo "" +echo "Manage VNC:" +echo " View status: sudo systemctl status vncserver.service" +echo " View logs: sudo journalctl -fu vncserver.service" +echo " Stop VNC: sudo systemctl stop vncserver.service"