-
Notifications
You must be signed in to change notification settings - Fork 27
/
entrypoint.sh
99 lines (94 loc) · 2.54 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
#!/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
unzip -q NapCat.Shell.zip -d ./NapCat.Shell
mv NapCat.Shell/config/* napcat/config/ && rmdir NapCat.Shell/config
mv NapCat.Shell/* napcat/
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:=''}
: ${NAPCAT_GID:=1001}
: ${NAPCAT_UID:=911}
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
rm -rf "/tmp/.X1-lock"
usermod -o -u ${NAPCAT_UID} napcat
groupmod -o -g ${NAPCAT_GID} napcat
usermod -g ${NAPCAT_GID} napcat
chown -R ${NAPCAT_UID}:${NAPCAT_GID} /app
gosu napcat Xvfb :1 -screen 0 1080x760x16 +extension GLX +render > /dev/null 2>&1 &
sleep 2
export FFMPEG_PATH=/usr/bin/ffmpeg
export DISPLAY=:1
cd /app/napcat
gosu napcat /opt/QQ/qq --no-sandbox -q $ACCOUNT