#!/bin/bash # 1. 清理锁文件 rm -f /tmp/.X99-lock # 清理 DBus 锁文件 (防止重启报错) rm -f /var/run/dbus/pid # 2. [新增] 启动 DBus 服务 # 这解决了 Failed to connect to socket /run/dbus/system_bus_socket 错误 mkdir -p /var/run/dbus dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address & # 3. 启动 Xvfb Xvfb :99 -ac -screen 0 1920x1080x24 -nolisten tcp & # 等待服务就绪 echo "Waiting for Xvfb and DBus..." sleep 3 # 4. 启动 Python python3 main_server.py