-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
38 lines (29 loc) · 1.65 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
#!/bin/bash
set -e
# we don't want to start EvoSC with root permissions
if [ "$2" = 'esc' -a "$(id -u)" = '0' ]; then
chown -R evosc /controller/esc
exec su-exec evosc "$0" "$@"
fi
if [ "$2" = 'esc' ]; then
[ ! -f /controller/config/theme.config.json ] && cp /controller/config/default/theme.config.json /controller/config/theme.config.json
[ ! -f /controller/config/database.config.json ] && cp /controller/config/default/database.config.json /controller/config/database.config.json
[ ! -f /controller/config/server.config.json ] && cp /controller/config/default/server.config.json /controller/config/server.config.json
databaseConfig=()
databaseConfig+=('.host = '\"${DB_HOST}\"'')
databaseConfig+=('| .db = '\"${DB_NAME}\"'')
databaseConfig+=('| .user = '\"${DB_USER}\"'')
databaseConfig+=('| .password = '\"${DB_PASSWORD}\"'')
eval jq \'${databaseConfig[@]}\' /controller/config/database.config.json > /controller/config/database.config.json.tmp
mv /controller/config/database.config.json.tmp /controller/config/database.config.json
serverConfig=()
serverConfig+=('.ip = '\"${RPC_IP}\"'')
serverConfig+=('| .port = '\"${RPC_PORT:-5000}\"'')
serverConfig+=('| .rpc.login = '\"${RPC_LOGIN:-SuperAdmin}\"'')
serverConfig+=('| .rpc.password = '\"${RPC_PASSWORD:-SuperAdmin}\"'')
serverConfig+=('| .["default-matchsettings"] = '\"${GAME_SETTINGS:-default.txt}\"'')
eval jq \'${serverConfig[@]}\' /controller/config/server.config.json > /controller/config/server.config.json.tmp
mv /controller/config/server.config.json.tmp /controller/config/server.config.json
[ ! -f /controller/cache/.setupfinished ] && touch /controller/cache/.setupfinished
fi
exec "$@"