[spam]
vivuu1989 opened this issue · comments
Vowner commented
it seems its very complex to insert xml content variable from shell script to a specific portion of xml based on the condition which satisfying
I have followed many threads in internet and couldn't find any solution to fulfill my requirement here.
HEADER=$(cat <<EOF
<policies>
EOF)
FOOTER==$(cat <<EOF
</policies>
EOF)
IN_IP_FILTER=$(cat <<EOF
<inbound>
<base />
<ip-filter action="allow">
<address-range from="$ipAddressesFrom" to="$ipAddressesTo" />
</ip-filter>
</inbound>
EOF)
################Variables##################
source parse_yaml.sh
eval $(parse_yaml sample2.yaml policy)
echo ".............Eval Result..............................."
for f in $policy_ ; do eval echo \$f \$${f}_ ; done
echo "............Eval Result................................"
echo " ********policy is ************ "
echo "{$IP_FILTER}"
for f in $policy_ ; do
if [[ $(eval echo \$${f}_name) == "ipfilter" ]]; then
echo " given policy name is ipfilter "
for g in $(eval echo \$${f}_session_); do
if [[ $(eval echo \$${g}) == "inbound" ]]; then
echo "add the add above Ipfilter string to the inbound session of xml"
echo "${HEADER}" >> result_$(eval echo \$${f}_name).xml
echo "${IN_IP_FILTER}" >> result_$(eval echo \$${f}_name).xml
fi
if [[ $(eval echo \$${g}) == "outbound" ]]; then
echo "add the add above Ipfilter string to the outbound session of xml"
fi
if [[ $(eval echo \$${g}) == "backend" ]]; then
echo "add the add above Ipfilter string to the backend session of xml"
fi
done
The file which need to customized based on the condition is as below , but need to replace only the content which is satisfying from the condition.
<policies>
<inbound>
<base />
$(ip_filter)
$(rate-limit-by_ip)
$(rate-limit-by_subkey)
$(rate-limit-by_DevID)
$(rate-limit-by_ip)+$(rate-limit-by_DevID)
</inbound>
<backend>
<base />
$(ip_filter)
$(rate-limit-by_ip)
$(rate-limit-by_subkey)
$(rate-limit-by_DevID)
$(rate-limit-by_ip)+$(rate-limit-by_DevID)
</backend>
<outbound>
<base />
$(ip_filter)
$(rate-limit-by_ip)
$(rate-limit-by_subkey)
$(rate-limit-by_DevID)
$(rate-limit-by_ip)+$(rate-limit-by_DevID)
</outbound>
<on-error>
<base />
$(rate-limit-by-ip_error)
$(rate-limit-by_DevID_error)
</on-error>
</policies>
Jordan Harband commented
I have absolutely no idea what this is about - nvm doesn't have any xml in it.