Pcmodcomputer / start.sh
THEZYZSTUDIO's picture
Update start.sh
7cc91ae verified
Raw
History Blame Contribute Delete
2.64 kB
#!/bin/bash
# ══════════════════════════════════════════════════
# THE Z AI β€” Computer Mode Startup (FIXED v4)
# ══════════════════════════════════════════════════
echo "πŸ–₯️ Starting Z Computer Mode Server v4..."
# ── 1. Start Virtual Display ─────────────────────
pkill Xvfb 2>/dev/null || true
sleep 0.5
Xvfb :1 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset &
XVFB_PID=$!
echo "βœ… Xvfb started (PID: $XVFB_PID)"
sleep 2
# ── 2. Export DISPLAY ─────────────────────────────
export DISPLAY=:1
export XAUTHORITY=/root/.Xauthority
# Ψ₯Ω†Ψ΄Ψ§Ψ‘ ملف xauthority Ψ¨Ψ·Ψ±ΩŠΩ‚Ψ© Ψ’Ω…Ω†Ψ©
touch $XAUTHORITY
MCOOKIE_VAL=$(mcookie 2>/dev/null || cat /proc/sys/kernel/random/uuid | tr -d '-' | head -c 32)
xauth add :1 . $MCOOKIE_VAL 2>/dev/null || true
echo "βœ… DISPLAY=$DISPLAY"
# ── 3. Dark background ────────────────────────────
xsetroot -solid "#0d0d0d" 2>/dev/null || true
# ── 4. Start Fluxbox WM ───────────────────────────
pkill fluxbox 2>/dev/null || true
fluxbox &
FLUX_PID=$!
echo "βœ… Fluxbox started (PID: $FLUX_PID)"
sleep 2
# ── 5. Verify display works ───────────────────────
echo "πŸ” Testing display..."
if xdotool getdisplaygeometry 2>/dev/null; then
echo "βœ… Display working!"
else
echo "⚠️ xdotool test failed β€” continuing anyway"
fi
# ── 6. Test screenshot ────────────────────────────
scrot -q 80 /tmp/test_shot.png 2>/dev/null && \
echo "βœ… Screenshot test: OK" || \
echo "⚠️ scrot test failed"
# ── 7. Detect browser (firefox-esr Ψ£ΩˆΩ„Ψ§Ω‹) ─────────
if command -v firefox-esr &>/dev/null; then
echo "βœ… Browser: firefox-esr"
BROWSER="firefox-esr"
elif command -v firefox &>/dev/null; then
echo "βœ… Browser: firefox"
BROWSER="firefox"
elif command -v chromium-browser &>/dev/null; then
echo "βœ… Browser: chromium-browser"
BROWSER="chromium-browser"
else
echo "⚠️ No browser found"
BROWSER=""
fi
# Export browser name so app.py can use it
export DEFAULT_BROWSER="$BROWSER"
echo "πŸš€ Starting Python API on port ${PORT:-7860}..."
cd /app
exec python3 app.py