File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8181chmod +x $SCRIPT_DIR /llbot/node
8282chmod +x $SCRIPT_DIR /llbot/pmhq
8383
84+ # 检测 FFmpeg 是否已安装
85+ if ! command -v ffmpeg & > /dev/null; then
86+ echo " 未检测到 FFmpeg,正在安装..."
87+ sudo apt-get install -y ffmpeg
88+ if [ $? -ne 0 ]; then
89+ echo " 警告:FFmpeg 安装失败,音视频处理功能可能受限"
90+ else
91+ echo " FFmpeg 安装完成"
92+ fi
93+ fi
94+
95+ # 寻找可用端口(从 13000 开始)
96+ find_available_port () {
97+ local port=$1
98+ while [ $port -lt 65535 ]; do
99+ if ! ss -tuln | grep -q " :$port " ; then
100+ echo $port
101+ return 0
102+ fi
103+ port=$(( port + 1 ))
104+ done
105+ echo " "
106+ return 1
107+ }
108+
109+ AVAILABLE_PORT=$( find_available_port 13000)
110+ if [ -z " $AVAILABLE_PORT " ]; then
111+ echo " 错误:无法找到可用端口"
112+ exit 1
113+ fi
114+
115+
84116# 检测 xvfb-run 命令是否存在
85117USE_XVFB=1
86118if ! command -v xvfb-run & > /dev/null; then
@@ -96,10 +128,12 @@ if ! command -v xvfb-run &> /dev/null; then
96128 fi
97129fi
98130
99- $SCRIPT_DIR /llbot/node $SCRIPT_DIR /llbot/llonebot.js &
100131
101132if [ $USE_XVFB -eq 1 ]; then
102- sudo xvfb-run $SCRIPT_DIR /llbot/pmhq
133+ sudo xvfb-run $SCRIPT_DIR /llbot/pmhq --port= $AVAILABLE_PORT &
103134else
104- sudo $SCRIPT_DIR /llbot/pmhq
135+ sudo $SCRIPT_DIR /llbot/pmhq --port= $AVAILABLE_PORT &
105136fi
137+ sleep 5
138+
139+ $SCRIPT_DIR /llbot/node $SCRIPT_DIR /llbot/llonebot.js -- --pmhq-port=$AVAILABLE_PORT &
You can’t perform that action at this time.
0 commit comments