#!/usr/bin/env bash function wait_until_iface_exists { IFACE=$1 echo "Waiting for interface ${IFACE}..." # Wait for the interface to come up (i.e., 'ip link show' returns 0) until ip link show $IFACE > /dev/null 2>&1; do sleep 1 done echo "Interface ${IFACE} is created" } # Wait for all interfaces to come up before starting the DHCP relay {% for (name, prefix) in INTERFACE %} wait_until_iface_exists {{ name }} {% endfor %} {% for (name, prefix) in VLAN_INTERFACE %} wait_until_iface_exists {{ name }} {% endfor %} {% for (name, prefix) in PORTCHANNEL_INTERFACE %} wait_until_iface_exists {{ name }} {% endfor %}