containers - use python hack to get env var values from string

This commit is contained in:
florian 2022-07-04 11:23:24 +02:00
parent 5ac80a135c
commit 738e3b6e1a
2 changed files with 4 additions and 2 deletions

View File

@ -61,7 +61,8 @@ if [ "$SWARM_MODE" != "yes" ] && [ "$KUBERNETES_MODE" != "yes" ] && [ "$AUTOCONF
fi
target="${target}${name}.conf"
log "ENTRYPOINT" "" "Saving custom config to $target ..."
echo "${!var_name}" > "$target"
content=$(python3 -c "import os ; print(os.environ['${var_name}'])")
echo "${content}" > "$target"
done
# execute temp nginx with no server

View File

@ -56,7 +56,8 @@ function get_env() {
for var_name in $(python3 -c 'import os ; [print(k) for k in os.environ]') ; do
filter=$(echo -n "$var_name" | sed -r 's/^(HOSTNAME|PWD|PKG_RELEASE|NJS_VERSION|SHLVL|PATH|_|NGINX_VERSION|HOME|([a-z\.\-]*)_?CUSTOM_CONF_(HTTP|DEFAULT_SERVER_HTTP|SERVER_HTTP|MODSEC|MODSEC_CRS)_(.*))$//g')
if [ "$filter" != "" ] ; then
echo "${var_name}=${!var_name}"
var_value=$(python3 -c "import os ; print(os.environ['${var_name}'])")
echo "${var_name}=${var_value}"
fi
done
}