Fixing roles variable filtering when exists

This commit is contained in:
2022-09-30 20:39:41 +00:00
parent f26c9dc1a2
commit 69921b224f

View File

@@ -31,6 +31,7 @@ set | grep ROLES
DEBUG=1
fi;
# finding IPv4 addresses from application names.
name_resolver() {
@@ -50,10 +51,10 @@ name_resolver() {
UPS=""
for ROLE in $(echo $ROLES); do
FILTERED_BY_ROLE=$(docker inspect $UP -f '{{.Config.Labels.roles}}' | uniq | grep $ROLE)
if [[ "$(echo $FILTERED_BY_ROLE)" != "" ]]; then
UPS="$UPS $UP";
fi
FILTERED_BY_ROLE=$(docker inspect $UP -f '{{.Name}} {{.Config.Labels.roles}}' | uniq | grep $ROLE| awk '{print $1}')
if [[ "$(echo $FILTERED_BY_ROLE)" != "" ]]; then
UPS="$UPS $FILTERED_BY_ROLE";
fi
done
UP=$UPS
@@ -166,7 +167,6 @@ prerouting() {
postrouting() {
if [[ ! -z "$SOURCE_IP" ]]; then
SOURCE_IP_FOR_POSTROUTING="$(echo $SOURCE_IP | cut -d . -f1-3).0/24";
debug "source ip is $SOURCE_IP_FOR_POSTROUTING"