initial commit

This commit is contained in:
Beu 2023-10-13 22:32:42 +02:00
commit 44936966d6
2 changed files with 137 additions and 0 deletions

32
Dockerfile Normal file
View File

@ -0,0 +1,32 @@
#Download base image debian 11
FROM debian:bullseye
# environment variables
ARG VERSION="Latest"
# Update repository
RUN apt-get update
# install dependencies
RUN apt-get install -y zip git vim wget xmlstarlet ncat xxd
# Prepare environment
RUN mkdir -p /opt/Trackmania
RUN wget -q -O /tmp/trackmania-server.zip "https://nadeo-download.cdn.ubi.com/trackmania/TrackmaniaServer_${VERSION}.zip"
RUN unzip /tmp/trackmania-server.zip -d /opt/Trackmania/
RUN rm -f /tmp/trackmania-server.zip
RUN cp -r /opt/Trackmania/UserData /opt/Trackmania/UserDataSaved
VOLUME /opt/Trackmania/UserData
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
WORKDIR /opt/Trackmania/
HEALTHCHECK --interval=5s --timeout=5s --start-period=20s --retries=3 \
CMD nc -z -v 127.0.0.1 5000 || exit 1
ENTRYPOINT ["/entrypoint.sh"]

105
entrypoint.sh Normal file
View File

@ -0,0 +1,105 @@
#!/bin/bash
set -e
cp -rf /opt/Trackmania/UserDataSaved/* /opt/Trackmania/UserData/
chmod +x TrackmaniaServer
# if no dedicated_cfg.txt is present, copy the defaults and create one
if [ ! "$DEDICATED_CFG" ]; then
DEDICATED_CFG_ARG=${MASTER_LOGIN:-dedicated_cfg}.txt
if [ ! "$NAME" ]; then
echo "You must have a the NAME environment variable set."
exit 1
fi
if [ ! "$MASTER_LOGIN" -a ! "$MASTER_PASSWORD" ]; then
echo "No config, master login or name given. Starting in LAN mode"
fi
if [ ! -f UserData/Config/${DEDICATED_CFG_ARG} ]; then
cp UserData/Config/dedicated_cfg.default.txt UserData/Config/${DEDICATED_CFG_ARG}
fi
# password escape workaround
if [ ${MASTER_PASSWORD+x} ]; then MASTER_PASSWORD=$(echo ${MASTER_PASSWORD} | sed -e 's/\$/\\\$/g' -e 's/`/\\`/g'); fi
configs=()
if [ ${SUPERADMIN_PASSWORD+x} ]; then configs+=("'/dedicated/authorization_levels/level[1]/password' -v \"${SUPERADMIN_PASSWORD}\""); fi
if [ ${ADMIN_PASSWORD+x} ]; then configs+=("'/dedicated/authorization_levels/level[2]/password' -v \"${ADMIN_PASSWORD}\""); fi
if [ ${USER_PASSWORD+x} ]; then configs+=("'/dedicated/authorization_levels/level[3]/password' -v \"${USER_PASSWORD}\""); fi
if [ ${MASTER_LOGIN+x} ]; then configs+=("'/dedicated/masterserver_account/login' -v \"${MASTER_LOGIN}\""); fi
if [ ${MASTER_PASSWORD+x} ]; then configs+=("'/dedicated/masterserver_account/password' -v \"${MASTER_PASSWORD}\""); fi
if [ "$NAME" ]; then configs+=("'/dedicated/server_options/name' -v \"${NAME}\""); fi
if [ "$MAX_PLAYERS" ]; then configs+=("'/dedicated/server_options/max_players' -v \"${MAX_PLAYERS}\""); fi
if [ ${PASSWORD+x} ]; then configs+=("'/dedicated/server_options/password' -v \"${PASSWORD}\""); fi
if [ "$MAX_SPECTATORS" ]; then configs+=("'/dedicated/server_options/max_spectators' -v \"${MAX_SPECTATORS}\""); fi
if [ ${PASSWORD_SPECTATORS+x} ]; then configs+=("'/dedicated/server_options/password_spectator' -v \"${PASSWORD_SPECTATORS}\""); fi
configs+=("'/dedicated/server_options/enable_p2p_upload' -v \"False\"")
configs+=("'/dedicated/server_options/enable_p2p_download' -v \"False\"")
if [ "$CALLVOTE_RATIO" ]; then configs+=("'/dedicated/server_options/callvote_ratio' -v \"${CALLVOTE_RATIO}\""); fi
#TODO: set callvote
configs+=("'/dedicated/system_config/server_port' -v \"2350\"")
configs+=("'/dedicated/system_config/xmlrpc_port' -v \"5000\"")
if [ "$ALLOW_MAP_DOWNLOAD" ]; then configs+=("'/dedicated/server_options/allow_map_download' -v \"${ALLOW_MAP_DOWNLOAD}\""); fi
if [ "$AUTOSAVE_REPLAYS" ]; then configs+=("'/dedicated/server_options/autosave_replays' -v \"${AUTOSAVE_REPLAYS}\""); fi
if [ "$AUTOSAVE_VALIDATION_REPLAYS" ]; then configs+=("'/dedicated/server_options/autosave_validation_replays' -v \"${AUTOSAVE_VALIDATION_REPLAYS}\""); fi
if [ "$DISABLE_HORNS" ]; then configs+=("'/dedicated/server_options/disable_horns' -v \"${DISABLE_HORNS}\""); fi
if [ "$DISABLE_PROFILE_SKINS" ]; then configs+=("'/dedicated/server_options/disable_profile_skins' -v \"${DISABLE_PROFILE_SKINS}\""); fi
if [ "$CLIENTINPUTS_MAXLATENCY" ]; then configs+=("'/dedicated/server_options/clientinputs_maxlatency' -v \"${CLIENTINPUTS_MAXLATENCY}\""); fi
if [ "$CONNECTION_UPLOADRATE" ]; then configs+=("'/dedicated/system_config/connection_uploadrate' -v \"${CONNECTION_UPLOADRATE}\""); fi
if [ "$CONNECTION_DOWNLOADRATE" ]; then configs+=("'/dedicated/system_config/connection_downloadrate' -v \"${CONNECTION_DOWNLOADRATE}\""); fi
if [ "$WORKERTHREADCOUNT" ]; then configs+=("'/dedicated/system_config/workerthreadcount' -v \"${WORKERTHREADCOUNT}\""); fi
if [ "$PACKETASSEMBLY_MULTITHREAD" ]; then configs+=("'/dedicated/system_config/packetassembly_multithread' -v \"${PACKETASSEMBLY_MULTITHREAD}\""); fi
if [ "$PACKETASSEMBLY_PACKETSPERFRAME" ]; then configs+=("'/dedicated/system_config/packetassembly_packetsperframe' -v \"${PACKETASSEMBLY_PACKETSPERFRAME}\""); fi
if [ "$PACKETASSEMBLY_FULLPACKETSPERFRAME" ]; then configs+=("'/dedicated/system_config/packetassembly_fullpacketsperframe' -v \"${PACKETASSEMBLY_FULLPACKETSPERFRAME}\""); fi
if [ "$DELAYEDVISUALS_S2C_SENDINGRATE" ]; then configs+=("'/dedicated/system_config/delayedvisuals_s2c_sendingrate' -v \"${DELAYEDVISUALS_S2C_SENDINGRATE}\""); fi
if [ "$TRUSTCLIENTSIMU_C2S_SENDINGRATE" ]; then configs+=("'/dedicated/system_config/trustclientsimu_c2s_sendingrate' -v \"${TRUSTCLIENTSIMU_C2S_SENDINGRATE}\""); fi
configs+=("'/dedicated/system_config/p2p_cache_size' -v \"0\"")
if [ "$FORCE_IP_ADDRESS" ]; then configs+=("'/dedicated/system_config/force_ip_address' -v \"${FORCE_IP_ADDRESS}\""); fi
if [ "$SERVER_PORT" ]; then configs+=("'/dedicated/system_config/server_port' -v \"${SERVER_PORT}\""); fi
configs+=("'/dedicated/system_config/xmlrpc_port' -v \"5000\"")
configs+=("'/dedicated/system_config/xmlrpc_allowremote' -v \"True\"")
if [ "$GUESTLIST_FILENAME" ]; then configs+=("'/dedicated/system_config/guestlist_filename' -v \"${GUESTLIST_FILENAME}\""); fi
if [ "$BLACKLIST_FILENAME" ]; then configs+=("'/dedicated/system_config/blacklist_filename' -v \"${BLACKLIST_FILENAME}\""); fi
if [ "$DISABLE_COHERENCE_CHECKS" ]; then configs+=("'/dedicated/system_config/disable_coherence_checks' -v \"${DISABLE_COHERENCE_CHECKS}\""); fi
if [ "$DISABLE_REPLAY_RECORDING" ]; then configs+=("'/dedicated/system_config/disable_replay_recording' -v \"${DISABLE_REPLAY_RECORDING}\"");
else configs+=("'/dedicated/system_config/disable_replay_recording' -v \"True\""); fi
if [ "$SAVE_ALL_INDIVIDUAL_RUNS" ]; then configs+=("'/dedicated/system_config/save_all_individual_runs' -v \"${SAVE_ALL_INDIVIDUAL_RUNS}\""); fi
# write config parameters into config file
for (( i = 0; i < ${#configs[@]} ; i++ )); do
eval xmlstarlet ed -L -P -u ${configs[$i]} UserData/Config/${DEDICATED_CFG_ARG}
done
else
DEDICATED_CFG_ARG=${DEDICATED_CFG}
fi
# finally populate the MatchSettings file
if [ "$MATCHSETTING_FILE" ]; then
MATCHSETTING=$MATCHSETTING_FILE
else
MATCHSETTING="tracklist.txt"
fi
if [ ! -f UserData/Maps/MatchSettings/${MATCHSETTING} ]; then
cp UserData/Maps/MatchSettings/example.txt UserData/Maps/MatchSettings/${MATCHSETTING}
fi
if [ "$SCRIPT_NAME" ]; then
sed -i "s#<script_name>.*<\/script_name>#<script_name>${SCRIPT_NAME}</script_name>#g" UserData/Maps/MatchSettings/${MATCHSETTING}
fi
exec ./TrackmaniaServer /nodaemon /nologs /dedicated_cfg=${DEDICATED_CFG_ARG} /game_settings=MatchSettings/${MATCHSETTING} $@