summaryrefslogtreecommitdiff
path: root/apps/compiler/includes/functions.sh
diff options
context:
space:
mode:
authorMike Delago <32778141+michaeldelago@users.noreply.github.com>2023-01-25 11:55:24 -0500
committerGitHub <noreply@github.com>2023-01-25 17:55:24 +0100
commitea51cdf0a6925954648dc7df6dda177792e303f2 (patch)
treef3dc6bc911fa9865c581a2c38a9b0eccafb9f61b /apps/compiler/includes/functions.sh
parent1fc0b5e04e7bc67a5339631cff7008919e8c92c3 (diff)
fix(Docker): config loading for ac-dev-server container (#14755)
## Changes Proposed: - This properly moves things from `DOCKER_ETC_FOLDER` to `confDir` - originally broken with https://github.com/azerothcore/azerothcore-wotlk/commit/888a718cf349f47b2230fdac0484df3a570bb898 ## Issues Addressed: - Should hopefully close https://github.com/azerothcore/acore-docker/issues/12 ## SOURCE: ## Tests Performed: - I'm not exactly aware of the testing procedure for this, as I don't use acore-docker - That said, the previous behavior has been replicated: https://github.com/azerothcore/azerothcore-wotlk/blob/2420d19e54eef2df6e9d997f0582d5d485920ecd/apps/compiler/includes/functions.sh#L148-L150 - Open to suggestions ## How to Test the Changes: 1. Open to Suggestions ## Known Issues and TODO List: - Test properly ## How to Test AzerothCore PRs When a PR is ready to be tested, it will be marked as **[WAITING TO BE TESTED]**. You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here: http://www.azerothcore.org/wiki/How-to-test-a-PR **REMEMBER**: when testing a PR that changes something **generic** (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but **especially** check that the PR does not cause any regression (i.e. introducing new bugs). **For example**: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but **we should test Y and Z as well**.
Diffstat (limited to 'apps/compiler/includes/functions.sh')
-rw-r--r--apps/compiler/includes/functions.sh29
1 files changed, 24 insertions, 5 deletions
diff --git a/apps/compiler/includes/functions.sh b/apps/compiler/includes/functions.sh
index a15f3b6597..5b26e065a1 100644
--- a/apps/compiler/includes/functions.sh
+++ b/apps/compiler/includes/functions.sh
@@ -147,11 +147,25 @@ function comp_compile() {
if [[ $DOCKER = 1 && $DISABLE_DOCKER_CONF != 1 ]]; then
echo "Generating confs..."
+
+ # Search for all configs under DOCKER_ETC_FOLDER
for dockerdist in "$DOCKER_ETC_FOLDER"/*.dockerdist; do
- base_conf="$(echo "$dockerdist" | rev | cut -f1 -d. --complement | rev)"
- cp -nv "$base_conf.dist" "$base_conf"
- # Move configs from .conf.dockerdist to .conf
- conf_layer "$dockerdist" "$base_conf" " # Copied from dockerdist"
+ # Grab "base" conf. turns foo.conf.dockerdist into foo.conf
+ baseConf="$(echo "$dockerdist" | rev | cut -f1 -d. --complement | rev)"
+ # env/dist/etc/foo.conf becomes foo.conf
+ filename="$(basename "$baseConf")"
+ # the dist files should be always found inside $confDir
+ # which may not be the same as DOCKER_ETC_FOLDER
+ distPath="$confDir/$filename.dist"
+ # if dist file doesn't exist, skip this iteration
+ [ ! -f "$distPath" ] && continue
+
+ # replace params in foo.conf.dist with params in foo.conf.dockerdist
+ conf_layer "$dockerdist" "$distPath" " # Copied from dockerdist"
+
+ # Copy modified dist file to $confDir/$filename
+ # Don't overwrite foo.conf if it already exists.
+ cp --no-clobber --verbose "$distPath" "$confDir/$filename"
done
fi
@@ -179,13 +193,18 @@ function conf_layer() {
BASE="$2"
COMMENT="$3"
+ # Loop over all defined params in conf file
grep -E "^[a-zA-Z\.0-9]+\s*=.*$" "$LAYER" \
| while read -r param
do
+ # remove spaces from param
+ # foo = bar becomes foo=bar
NOSPACE="$(tr -d '[:space:]' <<< "$param")"
+
+ # split into key and value
KEY="$(cut -f1 -d= <<< "$NOSPACE")"
VAL="$(cut -f2 -d= <<< "$NOSPACE")"
- # if key not in base or val not in line
+ # if key in base and val not in line
if grep -qE "^$KEY" "$BASE" && ! grep -qE "^$KEY.*=.*$VAL" "$BASE"; then
# Replace line
# Prevent issues with shell quoting