sonic-buildimage/dockers/docker-router-advertiser/wait_for_link.sh.j2
Joe LeVeque 1ee4fa5a40 [docker-radv] Fix startup issues (#5230)
**- Why I did it**

PR https://github.com/Azure/sonic-buildimage/pull/4599 introduced two bugs in the startup of the router advertiser container:

1. References to the `wait_for_intf.sh` script were changed to `wait_for_link.sh`, but the actual script was not renamed
2. The `ipv6_found` Jinja2 variable added to the supervisor config file goes out of scope before it is read.

**- How I did it**
1. Rename the `wait_for_intf.sh` script to `wait_for_link.sh`
2. Use the Jinja2 "namespace" construct to fix the scope issue

**- How to verify it**

Ensure all processes in the radv container start properly under the correct conditions (i.e., whether or not there is at least one VLAN with an IPv6 address assigned).
2020-09-04 21:20:08 +00:00

31 lines
701 B
Django/Jinja

#!/usr/bin/env bash
VLAN_TABLE_PREFIX="VLAN_TABLE"
function wait_until_iface_ready
{
TABLE_PREFIX=$1
IFACE=$2
echo "Waiting until interface $IFACE is ready..."
# Wait for the interface to come up
# (i.e., interface is present in STATE_DB and state is "ok")
while true; do
RESULT=$(sonic-db-cli STATE_DB HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null)
if [ x"$RESULT" == x"ok" ]; then
break
fi
sleep 1
done
echo "Interface ${IFACE} is ready!"
}
# Wait for all interfaces to be up and ready
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }}
{% endfor %}