From fc49573cedfce274a28ff5c34d40c28a8f965dff Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 16 Mar 2017 00:39:59 +0000 Subject: [PATCH] Wait for VLAN interface to come up before starting DHCP relay --- dockers/docker-dhcp-relay/Dockerfile | 7 ++++--- dockers/docker-dhcp-relay/start.sh | 12 ++++++++++++ files/build_templates/dhcp_relay.service.j2 | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100755 dockers/docker-dhcp-relay/start.sh diff --git a/dockers/docker-dhcp-relay/Dockerfile b/dockers/docker-dhcp-relay/Dockerfile index fbdabe333e6e..5c9ee3fb643b 100644 --- a/dockers/docker-dhcp-relay/Dockerfile +++ b/dockers/docker-dhcp-relay/Dockerfile @@ -15,8 +15,9 @@ RUN rm -rf /debs COPY ["isc-dhcp-relay.j2", "/usr/share/sonic/templates/"] COPY ["config.sh", "/usr/bin/"] +COPY ["start.sh", "/usr/bin/"] -ENTRYPOINT /usr/bin/config.sh \ - && service rsyslog start \ - && service isc-dhcp-relay start \ +ENTRYPOINT /usr/bin/config.sh \ + && service rsyslog start \ + && /usr/bin/start.sh \ && /bin/bash diff --git a/dockers/docker-dhcp-relay/start.sh b/dockers/docker-dhcp-relay/start.sh new file mode 100755 index 000000000000..05a7693268dc --- /dev/null +++ b/dockers/docker-dhcp-relay/start.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +VLAN_IFACE_NAME=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_vlan_interfaces[0]['name']"` + +# Wait for the VLAN to come up (i.e., 'ip link show' returns 0) +until ip link show $VLAN_IFACE_NAME > /dev/null 2>&1; do + sleep 1 +done + +# Start the DHCP relay +service isc-dhcp-relay start + diff --git a/files/build_templates/dhcp_relay.service.j2 b/files/build_templates/dhcp_relay.service.j2 index ee0c444ccce5..95d66c605f85 100644 --- a/files/build_templates/dhcp_relay.service.j2 +++ b/files/build_templates/dhcp_relay.service.j2 @@ -1,7 +1,7 @@ [Unit] Description=DHCP relay container Requires=docker.service -After=docker.service +After=interfaces-config.service [Service] User={{ sonicadmin_user }}