mirror of
https://github.com/NapNeko/NapCat-Docker.git
synced 2025-12-19 06:30:12 +08:00
101 lines
2.6 KiB
Bash
101 lines
2.6 KiB
Bash
#!/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
|
|
},
|
|
"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
|
|
|
|
chmod 777 /tmp &
|
|
rm -rf /run/dbus/pid &
|
|
mkdir -p /var/run/dbus &
|
|
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address &
|
|
Xvfb :1 -screen 0 1080x760x16 +extension GLX +render &
|
|
export FFMPEG_PATH=/usr/bin/ffmpeg
|
|
export DISPLAY=:1
|
|
cd ./napcat
|
|
qq --no-sandbox -q $ACCOUNT
|