diff --git a/README.md b/README.md index 05c001b..70f9339 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ Values can be passed into the server configuration file via environment variable On startup the container will look for any environment variables prefixed by `TES3MP_SERVER_` and attempt to update them on `tes3mp-server-default.cfg`. -Environment variables should be represented as uppercase snake case. +Syntax: `TES3MP_SERVER_
_` -For example `TES3MP_SERVER_MAXIMUM_PLAYERS` correlates to `maximumPlayers` in the configuration file. +For example `TES3MP_SERVER_GENERAL_MAXIMUM_PLAYERS` correlates to `[General] maximumPlayers` in the configuration file. ## Getting the image @@ -54,7 +54,7 @@ Replace the path described at the `-v` (volume) argument to a directory on your ```bash docker run -it \ --name TES3MP-server \ - -e TES3MP_SERVER_HOSTNAME="Containerized TES3MP Server" \ + -e TES3MP_SERVER_GENERAL_HOSTNAME="Containerized TES3MP Server" \ -v "$HOME/TES3MP/data:/server/data" \ -p "25565:25565/udp" \ tes3mp/server @@ -65,7 +65,7 @@ docker run -it \ ```bash docker run -it \ --name TES3MP-server \ - -e TES3MP_SERVER_HOSTNAME="Containerized TES3MP Server" \ + -e TES3MP_SERVER_GENERAL_HOSTNAME="Containerized TES3MP Server" \ -v "$HOME/TES3MP/data:/server/data" \ -p "25565:25565/udp" \ tes3mp/server:0.6.3 @@ -93,7 +93,7 @@ services: server: image: "tes3mp/server:0.6.3" environment: - - TES3MP_SERVER_HOSTNAME="Containerized TES3MP Server" + - TES3MP_SERVER_GENERAL_HOSTNAME="Containerized TES3MP Server" volumes: - "./data:/server/data" ports: @@ -102,7 +102,7 @@ services: server-legacy: image: "tes3mp/server:0.5.2" environment: - - TES3MP_SERVER_HOSTNAME="Containerized TES3MP Server (Legacy)" + - TES3MP_SERVER_GENERAL_HOSTNAME="Containerized TES3MP Server (Legacy)" volumes: - "./data-legacy:/server/data" ports: diff --git a/entrypoint.sh b/entrypoint.sh index b54e297..b4df309 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,18 +10,21 @@ fi printenv | grep 'TES3MP_SERVER_' | while read -r envvar do - declare -a envvar_exploded=(`echo "$envvar" |sed 's/=/ /g'`) - variable="${envvar_exploded[0]}" + declare -a envvar_exploded=(`echo "$envvar" | sed 's/=/ /g'`) + section_and_variable="${envvar_exploded[0]}" value="${envvar_exploded[@]:1}" - echo "Applying value of \"$variable\" to the configuration" - variable=$(echo "$variable" \ - | sed -e 's/TES3MP_SERVER_\(.*\)/\1/' \ + section_and_variable=$(echo "$section_and_variable" \ + | sed -e 's/TES3MP_SERVER_\([^_]*\)_\(.*\)/\1:\2/' \ | tr '[:upper:]' '[:lower:]' \ | awk -F "_" \ '{printf "%s", $1; \ for(i=2; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i,2); print"";}') + declare -a section_and_variable_exploded=(`echo "$section_and_variable" | sed 's/:/ /g'`) + section="${section_and_variable_exploded[0]}" + variable="${section_and_variable_exploded[1]}" + echo "Applying \"[$section] $variable = $value\" to the configuration" sed -i \ - "s/^\($variable =\).*$/\1 $value/" \ + "/\[$section\]/I,/\[/ s/\($variable =\).*$/\1 $value/" \ ./tes3mp-server-default.cfg done