rabbitmq-server/selenium/bin/gen-advanced-config

35 lines
1014 B
Bash
Executable File

#!/usr/bin/env bash
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#set -x
PROFILES=${1:?First parameter is a string of comma separated list of profiles}
TEST_PATH=${2:?First parameter is the directory env and config files are relative to}
ENV_FILE=${3:?Second parameter is a comma-separated list of .env file which has exported template variables}
FINAL_CONFIG_FILE=${4:?Forth parameter is the name of the final config file. It is relative to where this script is run from}
source $ENV_FILE
parentdir="$(dirname "$FINAL_CONFIG_FILE")"
mkdir -p $parentdir
echo "" > $FINAL_CONFIG_FILE
FOUND_TEMPLATES_COUNT=0
for f in $($SCRIPT/find-template-files "${PROFILES}" $TEST_PATH "advanced" "config")
do
envsubst < $f >> $FINAL_CONFIG_FILE
FOUND_TEMPLATES_COUNT+=1
done
if [ "$FOUND_TEMPLATES_COUNT" -gt 1 ]
then
echo "Matched $FOUND_TEMPLATES_COUNT advanced.config files. There should only match one"
exit -1
fi
if [ "$FOUND_TEMPLATES_COUNT" -lt 1 ]
then
rm $FINAL_CONFIG_FILE
exit -1
fi