fix: 修复自启动脚本

This commit is contained in:
Del Wang
2025-05-11 19:13:21 +08:00
parent 6bdd1b9683
commit e687280ab1
5 changed files with 143 additions and 17 deletions
+7 -4
View File
@@ -19,7 +19,7 @@ mkdir /data/open-xiaoai
# 设置 server 地址(注意替换成自己的 server 地址)
echo 'ws://192.168.31.227:4399' > /data/open-xiaoai/server.txt
# 运行启动脚本
# 运行启动脚本 init.sh
curl -sSfL https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-client/init.sh | sh
```
@@ -28,11 +28,14 @@ curl -sSfL https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-cli
>
> 注意安全!不要连接来路不明的 server 🚨
如果你想要开机自启动,可以运行以下命令,然后重启小爱音箱即可。
如果你想要开机自启动,运行以下命令重启小爱音箱即可。
```shell
# 下载到 /data/init.sh 开机时自启动
curl -L -o /data/init.sh https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-client/init.sh
# 下载 boot.sh 文件到 /data/init.sh 开机时自启动
curl -L -o /data/init.sh https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-client/boot.sh
# 重启小爱音箱
reboot
```
## 编译运行
+33
View File
@@ -0,0 +1,33 @@
#! /bin/sh
set -e
DOWNLOAD_BASE_URL="https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-client"
WORK_DIR="/data/open-xiaoai"
CLIENT_BIN="$WORK_DIR/client"
SERVER_ADDRESS="ws://127.0.0.1:4399" # 默认不会连接到任何 server
if [ ! -d "$WORK_DIR" ]; then
mkdir -p "$WORK_DIR"
fi
if [ ! -f "$CLIENT_BIN" ]; then
echo "🔥 正在下载 Client 端补丁程序..."
curl -L -# -o "$CLIENT_BIN" "$DOWNLOAD_BASE_URL/client"
chmod +x "$CLIENT_BIN"
echo "✅ Client 端补丁程序下载完毕"
fi
if [ -f "$WORK_DIR/server.txt" ]; then
SERVER_ADDRESS=$(cat "$WORK_DIR/server.txt")
fi
echo "🔥 正在启动 Client 端补丁程序..."
kill -9 `ps|grep "open-xiaoai/client"|grep -v grep|awk '{print $1}'` > /dev/null 2>&1 || true
"$CLIENT_BIN" "$SERVER_ADDRESS" > /dev/null 2>&1