THEZYZSTUDIO commited on
Commit
5ec1f34
Β·
verified Β·
1 Parent(s): bab52a4

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +25 -44
start.sh CHANGED
@@ -1,29 +1,11 @@
1
  #!/bin/bash
2
  # ══════════════════════════════════════════════════
3
- # THE Z AI β€” Computer Mode Startup (FIXED v2)
4
  # ══════════════════════════════════════════════════
5
 
6
- set -e
7
- echo "πŸ–₯️ Starting Z Computer Mode Server v2..."
8
 
9
- # ── 1. Install required tools if missing ────────────
10
- echo "πŸ“¦ Checking required packages..."
11
- apt-get update -qq 2>/dev/null || true
12
- apt-get install -y -qq \
13
- xvfb \
14
- fluxbox \
15
- firefox-esr \
16
- scrot \
17
- xdotool \
18
- xclip \
19
- x11-utils \
20
- imagemagick \
21
- python3-pip \
22
- 2>/dev/null || true
23
-
24
- echo "βœ… Packages ready"
25
-
26
- # ── 2. Start Virtual Display ─────────────────────
27
  pkill Xvfb 2>/dev/null || true
28
  sleep 0.5
29
  Xvfb :1 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset &
@@ -31,32 +13,25 @@ XVFB_PID=$!
31
  echo "βœ… Xvfb started (PID: $XVFB_PID)"
32
  sleep 2
33
 
34
- # ── 3. Export DISPLAY ─────────────────────────────
35
  export DISPLAY=:1
36
  export XAUTHORITY=/root/.Xauthority
37
 
38
- # Create Xauth
39
  touch $XAUTHORITY
40
  xauth generate :1 . trusted 2>/dev/null || true
41
  echo "βœ… DISPLAY=$DISPLAY"
42
 
43
- # ── 4. Set dark background ────────────────────────
44
  xsetroot -solid "#0d0d0d" 2>/dev/null || true
45
 
46
- # ── 5. Start Fluxbox WM ───────────────────────────
47
  pkill fluxbox 2>/dev/null || true
48
  fluxbox &
49
  FLUX_PID=$!
50
  echo "βœ… Fluxbox started (PID: $FLUX_PID)"
51
- sleep 1
52
-
53
- # ── 6. Launch Firefox ready ───────────────────────
54
- firefox-esr --no-sandbox --new-instance \
55
- --display=:1 2>/dev/null &
56
- echo "βœ… Firefox launched"
57
- sleep 3
58
 
59
- # ── 7. Verify display works ───────────────────────
60
  echo "πŸ” Testing display..."
61
  if xdotool getdisplaygeometry 2>/dev/null; then
62
  echo "βœ… Display working!"
@@ -64,23 +39,29 @@ else
64
  echo "⚠️ xdotool test failed β€” continuing anyway"
65
  fi
66
 
67
- # ── 8. Test screenshot ────────────────────────────
68
  scrot -q 80 /tmp/test_shot.png 2>/dev/null && \
69
  echo "βœ… Screenshot test: OK" || \
70
  echo "⚠️ scrot test failed"
71
 
72
- # ── 9. Install Python deps ────────────────────────
73
- echo "πŸ“¦ Installing Python packages..."
74
- pip3 install -q \
75
- fastapi==0.111.0 \
76
- "uvicorn[standard]==0.29.0" \
77
- websockets==12.0 \
78
- Pillow==10.3.0 \
79
- python-multipart==0.0.9
 
 
 
 
 
 
80
 
81
- echo "βœ… Python packages installed"
 
82
 
83
- # ── 10. Start Python API ──────────────────────────
84
  echo "πŸš€ Starting Python API on port ${PORT:-7860}..."
85
  cd /app
86
  exec python3 app.py
 
1
  #!/bin/bash
2
  # ══════════════════════════════════════════════════
3
+ # THE Z AI β€” Computer Mode Startup (FIXED v3)
4
  # ══════════════════════════════════════════════════
5
 
6
+ echo "πŸ–₯️ Starting Z Computer Mode Server v3..."
 
7
 
8
+ # ── 1. Start Virtual Display ─────────────────────
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  pkill Xvfb 2>/dev/null || true
10
  sleep 0.5
11
  Xvfb :1 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset &
 
13
  echo "βœ… Xvfb started (PID: $XVFB_PID)"
14
  sleep 2
15
 
16
+ # ── 2. Export DISPLAY ─────────────────────────────
17
  export DISPLAY=:1
18
  export XAUTHORITY=/root/.Xauthority
19
 
 
20
  touch $XAUTHORITY
21
  xauth generate :1 . trusted 2>/dev/null || true
22
  echo "βœ… DISPLAY=$DISPLAY"
23
 
24
+ # ── 3. Dark background ────────────────────────────
25
  xsetroot -solid "#0d0d0d" 2>/dev/null || true
26
 
27
+ # ── 4. Start Fluxbox WM ───────────────────────────
28
  pkill fluxbox 2>/dev/null || true
29
  fluxbox &
30
  FLUX_PID=$!
31
  echo "βœ… Fluxbox started (PID: $FLUX_PID)"
32
+ sleep 2
 
 
 
 
 
 
33
 
34
+ # ── 5. Verify display works ───────────────────────
35
  echo "πŸ” Testing display..."
36
  if xdotool getdisplaygeometry 2>/dev/null; then
37
  echo "βœ… Display working!"
 
39
  echo "⚠️ xdotool test failed β€” continuing anyway"
40
  fi
41
 
42
+ # ── 6. Test screenshot ────────────────────────────
43
  scrot -q 80 /tmp/test_shot.png 2>/dev/null && \
44
  echo "βœ… Screenshot test: OK" || \
45
  echo "⚠️ scrot test failed"
46
 
47
+ # ── 7. Detect browser ────────────────────────────
48
+ if command -v firefox &>/dev/null; then
49
+ echo "βœ… Browser: firefox"
50
+ BROWSER="firefox"
51
+ elif command -v firefox-esr &>/dev/null; then
52
+ echo "βœ… Browser: firefox-esr"
53
+ BROWSER="firefox-esr"
54
+ elif command -v chromium-browser &>/dev/null; then
55
+ echo "βœ… Browser: chromium-browser"
56
+ BROWSER="chromium-browser"
57
+ else
58
+ echo "⚠️ No browser found"
59
+ BROWSER=""
60
+ fi
61
 
62
+ # Export browser name so app.py can use it
63
+ export DEFAULT_BROWSER="$BROWSER"
64
 
 
65
  echo "πŸš€ Starting Python API on port ${PORT:-7860}..."
66
  cd /app
67
  exec python3 app.py