mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-09-04 02:46:23 +00:00
builder looks like it's working
This commit is contained in:
+6
-6
@@ -1,23 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
BLDR_NEW_SE+="# $BLDR_APP\n"
|
||||
BLDR_ENV_FILE+="# $BLDR_APP\n"
|
||||
BLDR_ENV_FILE+="COOKBOOK=$BLDR_PARENT_PATH #HELP: cookbooks\n"
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Use a regex to match and extract variable names and defaults
|
||||
if [[ $line =~ \$\{([A-Za-z_][A-Za-z0-9_]*)\} ]]; then
|
||||
# Matched ${VAR_NAME} (without default)
|
||||
var_name="${BASH_REMATCH[1]}"
|
||||
BLDR_NEW_SE+="${var_name}=\n"
|
||||
BLDR_ENV_FILE+="${var_name}=\n"
|
||||
elif [[ $line =~ \$\{([A-Za-z_][A-Za-z0-9_]*)[:-](.*)\} ]]; then
|
||||
# Matched ${VAR_DEF:-default} (with default)
|
||||
var_name="${BASH_REMATCH[1]}"
|
||||
default_value="${BASH_REMATCH[2]:1}"
|
||||
BLDR_NEW_SE+="${var_name}=${default_value}\n"
|
||||
BLDR_ENV_FILE+="${var_name}=${default_value}\n"
|
||||
fi
|
||||
done <<< "$BLDR_NEW_DCF"
|
||||
|
||||
# Remove duplicates from the output
|
||||
BLDR_NEW_SE=$(echo -e "$BLDR_NEW_SE" | sort -u)
|
||||
BLDR_ENV_FILE=$(echo -e "$BLDR_ENV_FILE" | sort -u)
|
||||
|
||||
echo "***** NEW sample.env *****"
|
||||
echo "$BLDR_NEW_SE"
|
||||
echo "$BLDR_ENV_FILE" > ${BLDR_DIR}/sample.env
|
||||
|
||||
Reference in New Issue
Block a user