forked from hansaes/autMan
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-entrypoint.sh
59 lines (51 loc) · 1.52 KB
/
docker-entrypoint.sh
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
52
53
54
55
56
57
58
59
#!/bin/sh
# 代码目录
if [ -z $CODE_DIR ]; then
CODE_DIR=/autMan
fi
# 获取当前系统架构
ARCH=$(uname -m)
# 如果构架为arm64,则使用arm64架构
if [ $ARCH = "x86_64" ]; then
ARCH="autMan_amd64.tar.gz"
elif [ $ARCH = "aarch64" ]; then
ARCH="autMan_arm64.tar.gz"
else
echo "不支持的架构"
exit 1
fi
# 代码目录不存在则拷贝
if [ ! -f $CODE_DIR/autMan ]; then
echo "autMan 不存在"
mkdir -p $CODE_DIR
cd $CODE_DIR
echo "下载 $ARCH"
API_RESPONSE=$(curl -s "https://api.github.com/repos/hdbjlizhe/fanli/releases/latest")
echo "API_RESPONSE: $API_RESPONSE"
# 预处理 JSON 字符串,去除控制字符
CLEAN_API_RESPONSE=$(echo "$API_RESPONSE" | tr -d '\n\r\t')
echo "CLEAN_API_RESPONSE: $CLEAN_API_RESPONSE"
browser_download_url=$(echo "$CLEAN_API_RESPONSE" | jq -r '.assets[] | select(.name == "'$ARCH'").browser_download_url')
echo "browser_download_url: $browser_download_url"
curl -L -o $ARCH "$browser_download_url"
echo "解压"
tar -zxvf $ARCH
echo "删除压缩包"
rm -f $ARCH
echo "安装 golang依赖"
cp $CODE_DIR/plugin/golang/go.mod $CODE_DIR/plugin/scripts/
cd $CODE_DIR/plugin/scripts
go get -u github.com/hdbjlizhe/middleware
go get github.com/buger/jsonparser
go get github.com/gin-gonic/gin
go get github.com/gin-contrib/sse
else
echo "autMan 存在"
fi
# 进入代码目录
chmod 777 $CODE_DIR
cd $CODE_DIR
echo -e "=================== 如果第一次配置机器人,请先配置机器人 ==================="
echo "启动"
chmod 777 autMan
./autMan