From 74799435dca411e9bb5aa59f4b8bdc6dd1384ad4 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Fri, 17 Apr 2026 20:20:01 +0100 Subject: add other config fields to env setting (with their types) --- entrypoint.bash | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/entrypoint.bash b/entrypoint.bash index c40fcd0..fbb0efc 100644 --- a/entrypoint.bash +++ b/entrypoint.bash @@ -20,19 +20,37 @@ if [ -d "/overlay" ]; then fi # handle configuration file changes via environment variables +# pattern is: even index is the field name, odd index is the type (String, Boolean, Integer) CONFIG_FIELDS=( + "MissionDirectory" + "String" + "ModdedServer" + "Boolean" + "Hidden" + "Boolean" "ServerName" - "MaxPlayers" + "String" "Password" + "String" + "MaxPlayers" + "Integer" + "DisableErrorKick" + "Boolean" + "NoPlayerStopTime" + "Integer" + "PostMissionDelay" + "Integer" + "RotationType" + "Integer" ) CONFIG_PATH="/app/DedicatedServerConfig.json" for FIELD in "${CONFIG_FIELDS[@]}"; do - ENV_VAR="CONFIG_${FIELD^^}" - if [ -n "${!ENV_VAR}" ]; then - echo "Setting $FIELD to ${!ENV_VAR} in config file." - jq --arg value "${!ENV_VAR}" ".${FIELD} = \$value" "$CONFIG_PATH" > tmp.$$.json && mv tmp.$$.json "$CONFIG_PATH" + ENV_VAR_NAME="CONFIG_${FIELD^^}" + if [ -n "${!ENV_VAR_NAME}" ]; then + echo "Setting $FIELD to ${!ENV_VAR_NAME} in $CONFIG_PATH" + jq --arg value "${!ENV_VAR_NAME}" --arg field "$FIELD" '(.[$field] // empty) |= ($value | if type == "boolean" then (if $value == "true" then true else false end) elif type == "number" then ($value | tonumber) else $value end)' "$CONFIG_PATH" > "$CONFIG_PATH.tmp" && mv "$CONFIG_PATH.tmp" "$CONFIG_PATH" fi done -- cgit v1.2.3