-
Notifications
You must be signed in to change notification settings - Fork 23
/
manage.sh
executable file
·77 lines (75 loc) · 1.72 KB
/
manage.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
#!/bin/bash
ENV_CONFIG_NAME=".env.prod"
if [ $# -eq 0 ]
then
echo "Usage: ./manage.sh [VERB] [OPTION...]"
echo "Verb: "
echo " Install"
echo " Start"
echo " Update"
echo "Option: "
echo " -t, --token Followed by token"
echo " -i, --id Followed by ID of QQ"
elif [ $1 = "install" ]
then
echo "Installing dependences."
sudo apt-get update
if [ $? -ne 0 ]
then
yum update
fi
sudo apt-get install -y locales locales-all fonts-noto libnss3-dev libxss1 libasound2 libxrandr2 libatk1.0-0 libgtk-3-0 libgbm-dev libxshmfence1
if [ $? -ne 0 ]
then
yum install -y at-spi2-atk libXcomposite libXdamage libXrandr mesa-libgbm libxkbcommon pango cairo
fi
echo "Installing HikariBot"
pip install nb-cli hikari-bot nonebot-plugin-gocqhttp
playwright install chromium
elif [ $1 = "start" ]
then
if [ -e ${ENV_CONFIG_NAME} ]
then
echo "OK"
nb run
else
ENV_CONFIG_EXAMPLE=`cat ${ENV_CONFIG_NAME}-example`
TOKEN=
QQ_ID=
NEXT_TOKEN=false
NEXT_QQ_ID=false
for name in $*
do
if [ ${NEXT_TOKEN} = ture ]
then
TOKEN=${name}
NEXT_TOKEN=false
elif [ ${NEXT_QQ_ID} = ture ]
then
QQ_ID=${name}
NEXT_QQ_ID=false
elif [[ ${name} = "-t" || ${name} = "--token" ]]
then
NEXT_TOKEN=ture
elif [[ ${name} = "-i" || ${name} = "--id" ]]
then
NEXT_QQ_ID=ture
fi
done
if [[ -z ${TOKEN} || -z ${QQ_ID} ]]
then
echo "Token and id of QQ must be given."
exit
fi
ENV_CONFIG_EXAMPLE=${ENV_CONFIG_EXAMPLE/'123456:qwertyuiopasdfghjl'/${TOKEN}}
ENV_CONFIG_EXAMPLE=${ENV_CONFIG_EXAMPLE/'1119809439'/${QQ_ID}}
echo "${ENV_CONFIG_EXAMPLE}" > ${ENV_CONFIG_NAME}
nb run
fi
elif [ $1 = "update" ]
then
pip install --upgrade hikari-bot
git pull
else
echo "Unrecognized verb $1."
fi