Rework Trackmania server

This commit is contained in:
fanyx 2022-06-26 17:41:12 +02:00
parent 839b000ef1
commit 716a54d4a5
5 changed files with 238 additions and 0 deletions

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8" ?>
<dedicated>
<authorization_levels>
<level>
<name>SuperAdmin</name>
<password>@SERVER_SA_PASSWORD@</password>
</level>
<level>
<name>Admin</name>
<password>@SERVER_ADM_PASSWORD@</password>
</level>
<level>
<name>User</name>
<password>User</password>
</level>
</authorization_levels>
<masterserver_account>
<login>@SERVER_LOGIN@</login>
<password>@SERVER_LOGIN_PASSWORD@</password>
<validation_key>@VALIDATION_KEY@</validation_key>
</masterserver_account>
<server_options>
<name>@SERVER_NAME@</name>
<comment>@SERVER_COMMENT@</comment>
<hide_server>@HIDE_SERVER@</hide_server> <!-- value is 0 (always shown), 1 (always hidden), 2 (hidden from nations) -->
<max_players>@MAX_PLAYERS@</max_players>
<password>@SERVER_PASSWORD@</password>
<max_spectators>32</max_spectators>
<password_spectator></password_spectator>
<ladder_mode>forced</ladder_mode> <!-- value between 'inactive', 'forced' (or '0', '1') -->
<ladder_serverlimit_min>0</ladder_serverlimit_min> <!-- Those values will be clamped to the limits authorized on http://official.trackmania.com/tmf-ladderserver/ -->
<ladder_serverlimit_max>50000</ladder_serverlimit_max>
<enable_p2p_upload>True</enable_p2p_upload>
<enable_p2p_download>True</enable_p2p_download>
<callvote_timeout>60000</callvote_timeout>
<callvote_ratio>0.5</callvote_ratio> <!-- default ratio. value in [0..1], or -1 to forbid. -->
<callvote_ratios>
<voteratio command="Ban" ratio="0.65"/>
<!-- commands can be "Ban", "Kick", "ChallengeRestart", "NextChallenge", ... -->
</callvote_ratios>
<allow_challenge_download>True</allow_challenge_download>
<autosave_replays>False</autosave_replays>
<autosave_validation_replays>False</autosave_validation_replays>
<referee_password></referee_password>
<referee_validation_mode>0</referee_validation_mode> <!-- value is 0 (only validate top3 players), 1 (validate all players) -->
<use_changing_validation_seed>False</use_changing_validation_seed>
</server_options>
<system_config>
<connection_uploadrate>512</connection_uploadrate> <!-- Kbps (kilo bits per second) -->
<connection_downloadrate>8192</connection_downloadrate> <!-- Kbps -->
<force_ip_address></force_ip_address>
<server_port>$SERVER_PORT</server_port>
<server_p2p_port>$SERVER_P2P_PORT</server_p2p_port>
<client_port>0</client_port>
<bind_ip_address></bind_ip_address>
<use_nat_upnp></use_nat_upnp>
<p2p_cache_size>600</p2p_cache_size>
<xmlrpc_port>5000</xmlrpc_port>
<xmlrpc_allowremote>True</xmlrpc_allowremote> <!-- If you specify an ip adress here, it'll be the only accepted adress. this will improve security. -->
<blacklist_url></blacklist_url>
<guestlist_filename></guestlist_filename>
<blacklist_filename></blacklist_filename>
<packmask>stadium</packmask>
<allow_spectator_relays>False</allow_spectator_relays>
<!-- <minimum_client_build>2009-10-01</minimum_client_build> -->
<!-- <disable_coherence_checks>laps</disable_coherence_checks> -->
<use_proxy>False</use_proxy>
<proxy_login></proxy_login>
<proxy_password></proxy_password>
</system_config>
</dedicated>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<playlist>
<gameinfos>
<game_mode>@GAMEMODE@</game_mode>
<chat_time>@CHATTIME@</chat_time>
<finishtimeout>@FINISHTIMEOUT@</finishtimeout>
<allwarmupduration>0</allwarmupduration>
<disablerespawn>@DISABLERESPAWN@</disablerespawn>
<forceshowallopponents>0</forceshowallopponents>
<rounds_pointslimit>@ROUNDS_POINTSLIMIT@</rounds_pointslimit>
<rounds_usenewrules>0</rounds_usenewrules>
<rounds_forcedlaps>0</rounds_forcedlaps>
<rounds_pointslimitnewrules>5</rounds_pointslimitnewrules>
<team_pointslimit>@TEAM_POINTSLIMIT@</team_pointslimit>
<team_maxpoints>@TEAM_MAXPOINTS@</team_maxpoints>
<team_usenewrules>0</team_usenewrules>
<team_pointslimitnewrules>5</team_pointslimitnewrules>
<timeattack_limit>@TIMEATTACK_LIMIT@</timeattack_limit>
<timeattack_synchstartperiod>0</timeattack_synchstartperiod>
<laps_nblaps>@LAPS_NBLAPS@</laps_nblaps>
<laps_timelimit>@LAPS_TIMELIMIT@</laps_timelimit>
<cup_pointslimit>@CUP_POINTSLIMIT@</cup_pointslimit>
<cup_roundsperchallenge>@CUP_ROUNDSPERCHALLENGE@</cup_roundsperchallenge>
<cup_nbwinners>@CUP_NBWINNERS@</cup_nbwinners>
<cup_warmupduration>@CUP_WARMUPDURATION@</cup_warmupduration>
</gameinfos>
<filter>
<is_lan>1</is_lan>
<is_internet>1</is_internet>
<is_solo>0</is_solo>
<is_hotseat>0</is_hotseat>
<sort_index>7</sort_index>
<random_map_order>0</random_map_order>
<force_default_gamemode>0</force_default_gamemode>
</filter>
<startindex>0</startindex>
</playlist>

72
tmserver/bin/eval_env.sh Executable file
View File

@ -0,0 +1,72 @@
#!/command/with-contenv bash
config=( )
playlist=( )
# Mandatory
SERVER_SA_PASSWORD=${SERVER_SA_PASSWORD:?ERROR | SuperAdminPassword needs to be set. Generate with pwgen if needed.} && \
config+=( "SERVER_SA_PASSWORD" )
SERVER_ADM_PASSWORD=${SERVER_ADM_PASSWORD:?ERROR | AdminPassword needs to be set. Generate with pwgen if needed.} && \
config+=( "SERVER_ADM_PASSWORD" )
SERVER_LOGIN=${SERVER_LOGIN?:ERROR | ServerLogin is missing. Server cannot start.} && \
config+=( "SERVER_LOGIN" )
SERVER_LOGIN_PASSWORD=${SERVER_LOGIN_PASSWORD?:ERROR | ServerLoginPassword is missing. Server cannot start.} && \
config+=( "SERVER_LOGIN_PASSWORD" )
# Optional
SERVER_PORT=${SERVER_PORT:-2350} && config+=( "SERVER_PORT" )
echo "INFO | SERVER_PORT: ${SERVER_PORT}"
SERVER_P2P_PORT=${SERVER_P2P_PORT:-3450} && config+=( "SERVER_P2P_PORT" )
echo "INFO | SERVER_P2P_PORT: ${SERVER_P2P_PORT}"
SERVER_NAME=${SERVER_NAME:-Trackmania Server} && config+=( "SERVER_NAME" )
echo "INFO | SERVER_NAME: ${SERVER_NAME}"
SERVER_COMMENT=${SERVER_COMMENT:-This is a Trackmania Server} && config+=( "SERVER_COMMENT" )
echo "INFO | SERVER_COMMENT: ${SERVER_COMMENT}"
SERVER_PASSWORD=${SERVER_PASSWORD} && config+=( "SERVER_PASSWORD" )
echo "INFO | SERVER_PASSWORD: ${SERVER_PASSWORD}"
HIDE_SERVER=${HIDE_SERVER:-0} && config+=( "HIDE_SERVER" )
echo "INFO | HIDE_SERVER: ${HIDE_SERVER}"
MAX_PLAYERS=${MAX_PLAYERS:-32} && config+=( "MAX_PLAYERS" )
echo "INFO | MAX_PLAYERS: ${MAX_PLAYERS}"
# Game Config
GAMEMODE=${GAMEMODE:-1} && playlist+=( "GAMEMODE" )
echo "INFO | GAMEMODE: ${GAMEMODE} | 1 = TimeAttack"
CHATTIME=${CHATTIME:-10000} && playlist+=( "CHATTIME" )
echo "INFO | CHATTTIME: ${CHATTIME} ms"
FINISHTIMEOUT=${FINISHTIMEOUT:-1} && playlist+=( "FINISHTIMEOUT" )
echo "INFO | FINISHTIMEOUT: ${FINISHTIMEOUT}"
DISABLERESPAWN=${DISABLERESPAWN:-0} && playlist+=( "DISABLERESPAWN" )
echo "INFO | DISABLERESPAWN: ${DISABLERESPAWN}"
ROUNDS_POINTSLIMIT=${ROUNDS_POINTSLIMIT:-30} && playlist+=( "ROUNDS_POINTSLIMIT" )
echo "INFO | ROUNDS_POINTSLIMIT: ${ROUNDS_POINTSLIMIT}"
TIMEATTACK_LIMIT=${TIMEATTACK_LIMIT:-180000} && playlist+=( "TIMEATTACK_LIMIT" )
echo "INFO | TIMEATTACK_LIMIT: ${TIMEATTACK_LIMIT} ms"
TEAM_POINTSLIMIT=${TEAM_POINTSLIMIT:-50} && playlist+=( "TEAM_POINTSLIMIT" )
echo "INFO | TEAM_POINTSLIMIT: ${TEAM_POINTSLIMIT}"
TEAM_MAXPOINTS=${TEAM_MAXPOINTS:-6} && playlist+=( "TEAM_MAXPOINTS" )
echo "INFO | TEAM_MAXPOINTS: ${TEAM_MAXPOINTS}"
LAPS_NBLAPS=${LAPS_NBLAPS:-5} && playlist+=( "LAPS_NBLAPS" )
echo "INFO | LAPS_NBLAPS: ${LAPS_NBLAPS}"
LAPS_TIMELIMIT=${LAPS_TIMELIMIT:-0} && playlist+=( "LAPS_TIMELIMIT" )
echo "INFO | LAPS_TIMELIMIT: ${LAPS_TIMELIMIT}"
CUP_POINTSLIMIT=${CUP_POINTSLIMIT:-100} && playlist+=( "CUP_POINTSLIMIT" )
echo "INFO | CUP_POINTSLIMIT: ${CUP_POINTSLIMIT}"
CUP_ROUNDSPERCHALLENGE=${CUP_ROUNDSPERCHALLENGE:-5} && playlist+=( "CUP_ROUNDSPERCHALLENGE" )
echo "INFO | CUP_ROUNDSPERCHALLENGE: ${CUP_ROUNDSPERCHALLENGE}"
CUP_NBWINNERS=${CUP_NBWINNERS:-3} && playlist+=( "CUP_NBWINNERS" )
echo "INFO | CUP_NBWINNERS: ${CUP_NBWINNERS}"
CUP_WARMUPDURATION=${CUP_WARMUPDURATION:-2} && playlist+=( "CUP_WARMUPDURATION" )
echo "INFO | CUP_WARMUPDURATION: ${CUP_WARMUPDURATION}"
# Parse config.xml
for idx in "${!config[@]}"; do
arg=${config[$idx]}
sed -i -e "s/@$arg@/${!arg}/g" GameData/Config/config.xml
done
# Parse playlist.xml
for idx in "${!playlist[@]}"; do
arg=${playlist[$idx]}
sed -i -e "s/@$arg@/${!arg}/g" GameData/Tracks/MatchSettings/playlist.xml
done

20
tmserver/bin/eval_playlist.sh Executable file
View File

@ -0,0 +1,20 @@
#!/command/with-contenv bash
echo "INFO | Parsing custom playlist..."
CUSTOM_PLAYLIST=${CUSTOM_PLAYLIST:-playlist.txt}
PLAYLIST_FILE='GameData/Tracks/MatchSettings/playlist.xml'
if [[ -f "${CUSTOM_PLAYLIST}" ]]; then
count=1
while read l; do
xmlstarlet ed -L -s /playlist -t elem -n challenge $PLAYLIST_FILE
xmlstarlet ed -L -s "/playlist/challenge[${count}]" -t elem -n file -v "${l}" $PLAYLIST_FILE
count=$((count+1))
done < $CUSTOM_PLAYLIST
else
xmlstarlet ed -L -s /playlist -t elem -n challenge $PLAYLIST_FILE
xmlstarlet ed -L -s "playlist/challenge[1]" -t elem -n file -v "Challenges/Nadeo/A01-Race.Challenge.Gbx" $PLAYLIST_FILE
fi
echo "INFO | Finished parsing playlist files."

15
tmserver/entrypoint.sh Executable file
View File

@ -0,0 +1,15 @@
#!/command/with-contenv bash
set -e
[[ "$(id -u)" == 0 ]] && s6-setuidgid trackmania "$0"
cd /var/lib/tmserver
# Parse config files
./bin/eval_env.sh
# Parse playlist files
./bin/eval_playlist.sh
exec "./TrackmaniaServer" "/nodaemon" "/internet" "/game_settings=MatchSettings/playlist.xml" "/dedicated_cfg=config.xml"