From 648000610948168d8c3e13783c09cd27497c4f80 Mon Sep 17 00:00:00 2001 From: zboinek Date: Fri, 15 May 2026 16:48:52 +0200 Subject: [PATCH] fix(runner): improve config merging logic to prevent overwriting specific settings --- runner/entrypoint.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/runner/entrypoint.sh b/runner/entrypoint.sh index 3e05115..49ee9ac 100755 --- a/runner/entrypoint.sh +++ b/runner/entrypoint.sh @@ -11,7 +11,12 @@ function _replace_conf() local REPLACE_WITH="${2}" local FILENAME="${3}" - sed -i "/^${SEARCH_FOR}/c\\${SEARCH_FOR} = ${REPLACE_WITH}" "${FILENAME}" + if grep -q "^${SEARCH_FOR}[[:space:]]*=" "${FILENAME}" + then + sed -i "s|^${SEARCH_FOR}[[:space:]]*=.*|${SEARCH_FOR} = ${REPLACE_WITH}|" "${FILENAME}" + else + echo "${SEARCH_FOR} = ${REPLACE_WITH}" >> "${FILENAME}" + fi } function _merge_confs() { @@ -22,7 +27,7 @@ function _merge_confs() do PROPERTY="$(echo "${LINE}" | cut -d '#' -f 1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - if [[ -n "${PROPERTY}" ]] + if [[ -n "${PROPERTY}" && "${PROPERTY}" == *"="* ]] then local SEARCH_FOR="$(echo "${PROPERTY}" | cut -d '=' -f 1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local REPLACE_WITH="$(echo "${PROPERTY}" | cut -d '=' -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" @@ -66,6 +71,18 @@ function compose_realmd_conf() _merge_confs realmd.conf "/opt/mangos/conf/realmd.conf" fi } +function compose_aiplayerbot_conf() +{ + cd "${MANGOS_DIR}/etc" + if [[ -f "aiplayerbot.conf.dist" ]] + then + cp aiplayerbot.conf.dist aiplayerbot.conf + if [[ -f "/opt/mangos/conf/aiplayerbot.conf" ]] + then + _merge_confs aiplayerbot.conf "/opt/mangos/conf/aiplayerbot.conf" + fi + fi +} function set_timezone() { @@ -88,6 +105,7 @@ function init_runner() compose_mangosd_conf compose_realmd_conf + compose_aiplayerbot_conf } function run_mangosd()