forked from NapNeko/NapCat-Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
100 lines (95 loc) · 2.51 KB
/
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
chech_quotes(){
local input="$1"
if [ "${input:0:1}" != '"' ] ; then
if [ "${input:0:1}" != '[' ] ; then
input="[\"$input\"]"
fi
else
input="[$input]"
fi
echo $input
}
# 安装 napcat
if [ ! -f "napcat/napcat.mjs" ]; then
rarch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/x64/)
unzip -q NapCat.linux.${rarch}.zip
mv NapCat.linux.${rarch}/config/* napcat/config/ && rmdir NapCat.linux.${rarch}/config
mv NapCat.linux.${rarch}/* napcat/
chmod +x napcat/napcat.sh
fi
CONFIG_PATH=napcat/config/onebot11_$ACCOUNT.json
# 容器首次启动时执行
if [ ! -f "$CONFIG_PATH" ]; then
if [ "$WEBUI_TOKEN" ]; then
echo "{\"port\": 6099,\"token\": \"$WEBUI_TOKEN\",\"loginRate\": 3}" > napcat/config/webui.json
fi
: ${WEBUI_TOKEN:=''}
: ${HTTP_PORT:=3000}
: ${HTTP_URLS:='[]'}
: ${WS_PORT:=3001}
: ${HTTP_ENABLE:='false'}
: ${HTTP_POST_ENABLE:='false'}
: ${WS_ENABLE:='false'}
: ${WSR_ENABLE:='false'}
: ${WS_URLS:='[]'}
: ${HEART_INTERVAL:=60000}
: ${TOKEN:=''}
: ${F2U_ENABLE:='false'}
: ${DEBUG_ENABLE:='false'}
: ${LOG_ENABLE:='false'}
: ${RSM_ENABLE:='false'}
: ${MESSAGE_POST_FORMAT:='array'}
: ${HTTP_HOST:=''}
: ${WS_HOST:=''}
: ${HTTP_HEART_ENABLE:='false'}
: ${MUSIC_SIGN_URL:=''}
: ${HTTP_SECRET:=''}
HTTP_URLS=$(chech_quotes $HTTP_URLS)
WS_URLS=$(chech_quotes $WS_URLS)
cat <<EOF > $CONFIG_PATH
{
"http": {
"enable": ${HTTP_ENABLE},
"host": "$HTTP_HOST",
"port": ${HTTP_PORT},
"secret": "$HTTP_SECRET",
"enableHeart": ${HTTP_HEART_ENABLE},
"enablePost": ${HTTP_POST_ENABLE},
"postUrls": $HTTP_URLS
},
"ws": {
"enable": ${WS_ENABLE},
"host": "${WS_HOST}",
"port": ${WS_PORT}
},
"reverseWs": {
"enable": ${WSR_ENABLE},
"urls": $WS_URLS
},
"GroupLocalTime":{
"Record": false,
"RecordList": []
},
"debug": ${DEBUG_ENABLE},
"heartInterval": ${HEART_INTERVAL},
"messagePostFormat": "$MESSAGE_POST_FORMAT",
"enableLocalFile2Url": ${F2U_ENABLE},
"musicSignUrl": "$MUSIC_SIGN_URL",
"reportSelfMessage": ${RSM_ENABLE},
"token": "$TOKEN"
}
EOF
fi
FILE="/tmp/.X1-lock"
if [ -e "$FILE" ]; then
rm -rf "$FILE"
echo "$FILE has been deleted."
else
echo "$FILE does not exist."
fi
Xvfb :1 -screen 0 1080x760x16 +extension GLX +render &
export FFMPEG_PATH=/usr/bin/ffmpeg
export DISPLAY=:1
cd ./napcat
qq --no-sandbox -q $ACCOUNT