containers - replace compgen command with a python hack because compgen -e do not display var with dots

This commit is contained in:
florian 2022-07-04 10:44:38 +02:00
parent 8f258486ef
commit 5ac80a135c
3 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ fi
if [ "$SWARM_MODE" != "yes" ] && [ "$KUBERNETES_MODE" != "yes" ] && [ "$AUTOCONF_MODE" != "yes" ] ; then
# extract and drop configs
for var_name in $(compgen -e) ; do
for var_name in $(python3 -c 'import os ; [print(k) for k in os.environ]') ; do
extracted=$(echo "$var_name" | sed -r 's/^([a-z\.\-]*)_?CUSTOM_CONF_(HTTP|DEFAULT_SERVER_HTTP|SERVER_HTTP|MODSEC|MODSEC_CRS)_(.*)$/\1 \2 \3/g')
site=$(echo "$extracted" | cut -d ' ' -f 1)
type=$(echo "$extracted" | cut -d ' ' -f 2 | grep -E '(HTTP|DEFAULT_SERVER_HTTP|SERVER_HTTP|MODSEC|MODSEC_CRS)' | tr '[:upper:]' '[:lower:]' | sed 's/_/-/')

View File

@ -53,7 +53,7 @@ function log() {
# get only interesting env (var=value)
function get_env() {
for var_name in $(compgen -e) ; do
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}"

View File

@ -163,7 +163,7 @@ function curl_assert() {
if [ "$ws" = "" ] ; then
data="$(curl -k -L -s --cookie /dev/null -H "User-Agent: LegitOne" "$url" | grep -i "$str")"
else
data="$(echo "test" | /tmp/websocat_amd64-linux - --text wss://test1.bunkerity.com/ws/ | grep -i "$str")"
data="$(echo "test" | /tmp/websocat_amd64-linux - --text "$url" | grep -i "$str")"
fi
if [ "$data" != "" ] && [ $? -eq 0 ] ; then
return 0