#!/bin/bash # 1. 清理锁文件 rm -f /tmp/.X99-lock # 清理 DBus 锁文件 (防止重启报错) rm -f /var/run/dbus/pid # 2. [新增] 启动 DBus 服务 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. 执行传递给容器的命令 # 如果没有传命令,默认执行 python3 main_sentinel.py (为了兼容你以前的习惯) if [ $# -eq 0 ]; then exec python3 main_sentinel.py else exec "$@" fi