-
Notifications
You must be signed in to change notification settings - Fork 5
/
docker_run.sh
63 lines (62 loc) · 2.94 KB
/
docker_run.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
#!/bin/sh
# Do **NOT** run this script locally,
# it is meant to only be used in the provided docker environment.
# create and copy dedicated config
if find /app/server/GameData/Config -mindepth 1 -maxdepth 1 | read; then
echo 'Server config exists, skipping initial setup.'
rm dedicated_cfg.txt.bk
else
echo 'Setting up server...'
# cool and ugly xml replacement
xml ed -L -u "/dedicated/authorization_levels/level[name='SuperAdmin']/password" -v "$SUPER_ADMIN_PASSWORD" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/authorization_levels/level[name='SuperAdmin']/name" -v "$SUPER_ADMIN_NAME" dedicated_cfg.txt.bk
ADMIN_PASS=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c"${1:-32}";echo;)
xml ed -L -u "/dedicated/authorization_levels/level[name='Admin']/password" -v "$ADMIN_PASS" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/masterserver_account/login" -v "$SERVER_ACC_LOGIN" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/masterserver_account/password" -v "$SERVER_ACC_PASSWORD" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/masterserver_account/validation_key" -v "$SERVER_ACC_KEY" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/server_options/name" -v "$SERVER_NAME" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/server_options/password" -v "$SERVER_PASSWORD" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/system_config/server_port" -v "$SERVER_NET_PORT" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/system_config/server_p2p_port" -v "$SERVER_P2P_PORT" dedicated_cfg.txt.bk
xml ed -L -u "/dedicated/system_config/xmlrpc_port" -v "$SERVER_PORT" dedicated_cfg.txt.bk
mv /app/server/dedicated_cfg.txt.bk /app/server/GameData/Config/dedicated_cfg.txt
fi
# copy over default tracks
if find /app/server/GameData/Tracks -mindepth 1 -maxdepth 1 | read; then
echo 'Tracks exist, skipping initial setup.'
rm -r Tracksbk
else
echo 'Setting up tracks...'
mv /app/server/Tracksbk/* /app/server/GameData/Tracks/
fi
# copy over trakman directory
if find /app/server/trakman -mindepth 1 -maxdepth 1 | read; then
echo 'Trakman exists, skipping initial setup.'
rm -r trakmanbk
else
echo 'Setting up trakman...'
mv /app/server/trakmanbk/* /app/server/trakman/
fi
# ugly creating of files to be able to chmod and remove them later
mkdir -p trakman/logs
touch trakman/logs/combined.log
touch trakman/logs/error.log
touch trakman/logs/info.log
mkdir -p .pm2/logs
touch .pm2/logs/Trakman-error.log
touch .pm2/logs/Trakman-out.log
mkdir -p trakman/temp
touch trakman/temp/rank_coherence.txt
mkdir -p trakman/plugins/server_links/temp
touch trakman/plugins/server_links/temp/data.txt
chown -R server:server /app/server
# build and actually run everything
echo "#!/bin/sh
/app/server/TrackmaniaServer /game_settings=MatchSettings/MatchSettings.txt /dedicated_cfg=dedicated_cfg.txt
npm run build --prefix /app/server/trakman
chmod -R a+w /app/server
npm run daemon --prefix /app/server/trakman" > run.sh
chown server:server run.sh
chmod 766 run.sh
exec su-exec server ./run.sh