From c230f02b2e49ab40506c5d591c882d507ab04e23 Mon Sep 17 00:00:00 2001 From: Hendrik Boll Date: Tue, 17 Sep 2019 22:29:32 +0200 Subject: [PATCH] entrypoint script - added neccessary variables - updated Dockerfile --- docker-tmserver/Dockerfile | 6 +-- docker-tmserver/entrypoint-tmserver.sh | 68 ++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/docker-tmserver/Dockerfile b/docker-tmserver/Dockerfile index e15ab54..2d696ff 100644 --- a/docker-tmserver/Dockerfile +++ b/docker-tmserver/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:stretch-slim +FROM debian:buster-slim RUN mkdir /opt/tmserver @@ -18,6 +18,4 @@ RUN chown trackmania:trackmania /entrypoint-tmserver.sh USER trackmania WORKDIR /opt/tmserver -ENTRYPOINT ["entrypoint-tmserver.sh"] - -CMD ["TrackmaniaServer","/nodaemon"] +ENTRYPOINT ["./entrypoint-tmserver.sh"] diff --git a/docker-tmserver/entrypoint-tmserver.sh b/docker-tmserver/entrypoint-tmserver.sh index 10debf6..950667d 100755 --- a/docker-tmserver/entrypoint-tmserver.sh +++ b/docker-tmserver/entrypoint-tmserver.sh @@ -3,6 +3,11 @@ set -e +if [[ "$(id -u)" = "0"]]; then + chown -R trackmania /opt/tmserver + exec su-exec trackmania "$0" +fi + # Evaluate all the available environment variables if [[ -z "${SERVER_LOGIN}" ]]; then echo "Server account login is missing. Server cannot start." @@ -41,11 +46,66 @@ if [[ -z "${SERVER_COMMENT}" ]]; then SERVER_COMMENT="This is a Trackmania Server" fi -# Evaluation over -# Commencing substition in config files +if [[ -z "${GAMEMODE}"]]; then + echo "No gamemode was specified. Defaulting to TimeAttack." + GAMEMODE=1 +fi + +if [[ -z "${CHATTIME}"]]; then + echo "No chat timeout was specified. Defaulting to 10000 ms." + CHATTIME=10000 +fi + +if [[ -z "${FINISHTIMEOUT}"]]; then + echo "No finish timeout was specified. Defaulting to adaptive mode." + FINISHTIMEOUT=1 +fi + +if [[ -z "${DISABLERESPAWN}"]]; then + echo "Respawns were not specified. Defaulting to enabled." + DISABLERESPAWN=0 +fi + +if [[ -z "${ROUNDS_POINTSLIMIT}"]]; then + echo "No points limit was specified for rounds mode. Defaulting to 30." + ROUNDS_POINTSLIMIT=30 +fi + +if [[ -z "${TIMEATTACK_LIMIT}"]]; then + echo "No time limit was specified for time attack mode. Defaulting to 180000 ms." + TIMEATTACK_LIMIT=180000 +fi + +if [[ -z "${TEAM_POINTSLIMIT}"]]; then + echo "No points limit was specified for team mode. Defaulting to 50." + TEAM_POINTSLIMIT=50 +fi + +if [[ -z "${TEAM_MAXPOINTS}"]]; then + echo "No number of maximum points per round was specified for team mode. Defaulting to 6." + TEAM_MAXPOINTS=6 +fi + +if [[ -z "${LAPS_NBLAPS}"]]; then + echo "No number of laps was specified for laps mode. Defaulting to 5." + LAPS_NBLAPS=5 +fi + +if [[ -z "${LAPS_TIMELIMIT}"]]; then + echo "No time limit was specified for laps mode. Defaulting to no limit." + LAPS_TIMELIMIT=0 +fi + + +echo "Evaluation over" +echo "Substition in config files" #Trackmania Files -envsubst > GameData/Config/config.txt < GameData/Config/_config.txt +$configcmd="envsubst > GameData/Config/config.txt < GameData/Config/_config.txt" +$playlistcmd="envsubst > GameData/Config/playlist.txt < GameData/Config/_playlist.txt" -exec "./TrackmaniaServer" "/nodaemon" "/internet" "/game_settings=MatchSettings/playlist.txt" "/dedicated_cfg=config.txt" +eval $configcmd +eval $playlistcmd + +exec "/opt/tmserver/TrackmaniaServer" "/nodaemon" "/internet" "/game_settings=MatchSettings/playlist.txt" "/dedicated_cfg=config.txt"