[DHCP Relay]: Wait for all interfaces to come up before starting DHCP relay (#660)
This commit is contained in:
parent
984e6c4bc9
commit
e0d22acc9e
@ -1,16 +1,41 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create isc-dhcp-relay config file
|
||||||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isc-dhcp-relay.j2 > /etc/default/isc-dhcp-relay
|
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isc-dhcp-relay.j2 > /etc/default/isc-dhcp-relay
|
||||||
|
|
||||||
rm -f /var/run/rsyslogd.pid
|
rm -f /var/run/rsyslogd.pid
|
||||||
|
|
||||||
supervisorctl start rsyslogd
|
supervisorctl start rsyslogd
|
||||||
|
|
||||||
VLAN_IFACE_NAME=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_vlan_interfaces[0]['attachto']"`
|
# Wait for all interfaces to come up before starting the DHCP relay
|
||||||
|
|
||||||
# Wait for the VLAN to come up (i.e., 'ip link show' returns 0)
|
FRONT_PANEL_IFACES=$(sonic-cfggen -m /etc/sonic/minigraph.xml --var-json "minigraph_interfaces" | grep "\"attachto\":" | sed 's/^\s*"attachto":\s"\(.*\)".*$/\1/')
|
||||||
until ip link show $VLAN_IFACE_NAME > /dev/null 2>&1; do
|
for IFACE in $FRONT_PANEL_IFACES; do
|
||||||
sleep 1
|
wait_until_iface_exists $IFACE
|
||||||
|
done
|
||||||
|
|
||||||
|
VLAN_IFACES=$(sonic-cfggen -m /etc/sonic/minigraph.xml --var-json "minigraph_vlan_interfaces" | grep "\"attachto\":" | sed 's/^\s*"attachto":\s"\(.*\)".*$/\1/')
|
||||||
|
for IFACE in $VLAN_IFACES; do
|
||||||
|
wait_until_iface_exists $IFACE
|
||||||
|
done
|
||||||
|
|
||||||
|
PORTCHANNEL_IFACES=$(sonic-cfggen -m /etc/sonic/minigraph.xml --var-json "minigraph_portchannel_interfaces" | grep "\"attachto\":" | sed 's/^\s*"attachto":\s"\(.*\)".*$/\1/')
|
||||||
|
for IFACE in $PORTCHANNEL_IFACES; do
|
||||||
|
wait_until_iface_exists $IFACE
|
||||||
done
|
done
|
||||||
|
|
||||||
# Start the DHCP relay
|
# Start the DHCP relay
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=DHCP relay container
|
Description=DHCP relay container
|
||||||
Requires=docker.service
|
Requires=docker.service
|
||||||
After=interfaces-config.service
|
After=swss.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User={{ sonicadmin_user }}
|
User={{ sonicadmin_user }}
|
||||||
|
Reference in New Issue
Block a user