OsamaBinLikhon commited on
Commit
8c9319a
Β·
verified Β·
1 Parent(s): 118a4bf

Enhancement: Add VNC desktop environment integration

Browse files
Files changed (1) hide show
  1. start_vnc.sh +75 -0
start_vnc.sh ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # VNC and Gradio Startup Script
4
+ # This script starts VNC server, web bridge, and Gradio interface
5
+
6
+ set -e
7
+
8
+ echo "πŸš€ Starting VNC Desktop Environment..."
9
+
10
+ # Start VNC server
11
+ echo "πŸ“Ί Starting VNC server on port $VNC_PORT..."
12
+ export VNC_PORT=${VNC_PORT:-5901}
13
+ export VNC_PASSWORD=${VNC_PASSWORD:-computer-agent}
14
+
15
+ # Set VNC display
16
+ export DISPLAY=:99
17
+
18
+ # Kill any existing VNC servers
19
+ pkill -f vnc || true
20
+ pkill -f websockify || true
21
+
22
+ # Start VNC server in background
23
+ echo "πŸ”§ Starting TigerVNC server..."
24
+ vncserver :99 -geometry 1920x1080 -depth 24 -PasswordFile=/root/.vnc/passwd &
25
+ VNC_PID=$!
26
+
27
+ echo "VNC server started with PID: $VNC_PID"
28
+
29
+ # Wait for VNC server to be ready
30
+ sleep 3
31
+
32
+ # Start websockify to bridge VNC to web
33
+ echo "🌐 Starting Websockify bridge..."
34
+ websockify --web /usr/share/novnc 0.0.0.0:$VNC_PORT &
35
+ WEBSOCKIFY_PID=$!
36
+
37
+ echo "Websockify started with PID: $WEBSOCKIFY_PID"
38
+
39
+ # Start XFCE4 desktop environment
40
+ echo "πŸ–₯️ Starting XFCE4 desktop..."
41
+ export XDG_RUNTIME_DIR=/tmp/runtime-root
42
+ export QT_X11_NO_MITSHM=1
43
+
44
+ # Wait a bit more for VNC to be fully ready
45
+ sleep 2
46
+
47
+ # Start desktop environment in background
48
+ startxfce4 &
49
+ DESKTOP_PID=$!
50
+
51
+ echo "Desktop environment started with PID: $DESKTOP_PID"
52
+
53
+ # Give desktop environment time to start
54
+ sleep 5
55
+
56
+ echo "βœ… VNC environment is ready!"
57
+ echo "πŸ”— VNC Port: $VNC_PORT"
58
+ echo "πŸ”— Web Interface: http://localhost:7860"
59
+
60
+ # Function to cleanup on exit
61
+ cleanup() {
62
+ echo "πŸ›‘ Shutting down services..."
63
+ kill $VNC_PID $WEBSOCKIFY_PID $DESKTOP_PID 2>/dev/null || true
64
+ pkill -f vnc || true
65
+ pkill -f websockify || true
66
+ pkill -f startxfce4 || true
67
+ exit 0
68
+ }
69
+
70
+ # Trap cleanup signals
71
+ trap cleanup SIGTERM SIGINT
72
+
73
+ # Start Gradio interface in foreground
74
+ echo "🌐 Starting Computer-Using Agent interface..."
75
+ python computer_agent.py