-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·51 lines (40 loc) · 1.78 KB
/
deploy.sh
File metadata and controls
executable file
·51 lines (40 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -e
GITHUB_BASE="https://github.com/AstrBotDevs/AstrBot"
DATA_DIR="/your/docker_data/astrbot"
echo "当前使用源:${GITHUB_BASE}"
# 获取版本号
REMOTE_VERSION=$(curl -sI ${GITHUB_BASE}/releases/latest | grep -i location | awk -F '/' '{print $NF}' | tr -d '\r')
if [ -z "$REMOTE_VERSION" ]; then
echo "无法获取远程版本号,请检查网络"
exit 1
fi
VERSION_FILE="./docker/.astrbot_version"
LOCAL_VERSION=$(cat "$VERSION_FILE" 2>/dev/null || echo "")
# 比对并执行不同逻辑
if [ "$REMOTE_VERSION" == "$LOCAL_VERSION" ]; then
echo "当前版本 ($LOCAL_VERSION) 已是最新,若配置改变重建容器"
docker compose -p gateway -f "astrbot.yml" up -d
else
echo "检测到新版本: $REMOTE_VERSION (本地: ${LOCAL_VERSION:-无})"
# 下载与解压源码
curl -L "https://codeload.github.com/AstrBotDevs/AstrBot/zip/refs/tags/${REMOTE_VERSION}" -o ./docker/AstrBot.zip
unzip -q ./docker/AstrBot.zip -d ./docker
mv ./docker/AstrBot-* ./docker/AstrBot
# 下载 dashboard
curl -L "https://github.com/AstrBotDevs/AstrBot/releases/download/${REMOTE_VERSION}/AstrBot-${REMOTE_VERSION}-dashboard.zip" -o ./docker/AstrBot-dashboard.zip
rm -rf "${DATA_DIR}/dist"
unzip -q ./docker/AstrBot-dashboard.zip -d "${DATA_DIR}"
# 覆盖自定义 Dockerfile
cp ./docker/Dockerfile ./docker/AstrBot
# 构建
docker build -t astrbot:latest ./docker/AstrBot --network host \
--build-arg HTTP_PROXY=http://127.0.0.1:7890 \
--build-arg HTTPS_PROXY=http://127.0.0.1:7890
# 清理并记录版本
rm -rf ./docker/AstrBot*
echo "$REMOTE_VERSION" > "$VERSION_FILE"
# 启动/重建容器
docker compose -p gateway -f "astrbot.yml" up -d
echo "升级完成,当前版本: $REMOTE_VERSION"
fi