aboutsummaryrefslogtreecommitdiff
path: root/ci/container/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/container/run.sh')
-rw-r--r--ci/container/run.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/ci/container/run.sh b/ci/container/run.sh
index d829509..8e4f3cd 100644
--- a/ci/container/run.sh
+++ b/ci/container/run.sh
@@ -2,6 +2,18 @@
#this script will be invoked by dumb-init in the container on statup and is located at /app
+substitute_config_file() {
+ local templateFilePath="$1"
+ local outputFilePath="$2"
+
+ # Substitute environment variables with their values or default values
+ while IFS= read -r line; do
+ # Use pattern matching and parameter expansion to handle defaults
+ modifiedLine=$(echo "$line" | sed -E 's/\$\{([^:-]+)(:-([^}]+))?\}/$(echo "${\1:-\3}")/ge')
+ eval "echo \"$modifiedLine\""
+ done < "$templateFilePath" > "$outputFilePath"
+}
+
echo "Generating configuration files"
rm -rf config && mkdir config
@@ -11,7 +23,7 @@ cp config-templates/routes.xml config/routes.xml
#substitude all -template files in the config-templates dir and write them to the config dir
for file in config-templates/*-template.json; do
- envsubst < $file > config/$(basename $file -template.json).json
+ substitute_config_file $file config/$(basename $file -template.json).json
done
echo "Complete"