aboutsummaryrefslogtreecommitdiffstats
path: root/docker/wait_for_net.sh
diff options
context:
space:
mode:
authorStephane Desneux <stephane.desneux@iot.bzh>2016-11-30 20:33:52 +0100
committerStephane Desneux <stephane.desneux@iot.bzh>2016-11-30 20:37:12 +0100
commit6643e51c254d2dfed65f03568d1ce11e000f01c3 (patch)
tree21e49ccd23ea04e241cb5b7cd52d80164e2a3d2d /docker/wait_for_net.sh
parent46067f331f1acb9512795a04b6f2f095b5470ecd (diff)
Initial content
Change-Id: I330ad2e8b08a4743e752b8fe9d1ccf9fa1215f8a Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
Diffstat (limited to 'docker/wait_for_net.sh')
-rwxr-xr-xdocker/wait_for_net.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/docker/wait_for_net.sh b/docker/wait_for_net.sh
new file mode 100755
index 0000000..354e76a
--- /dev/null
+++ b/docker/wait_for_net.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+### this script is used as entrypoint of the docker container to wait for network to be up ###
+
+IFACE="veth0 eth0"
+
+function wait_net() {
+ for i in $IFACE; do
+ [[ "$(cat /sys/class/net/$i/operstate 2>/dev/null)" == "up" ]] && return 1
+ done
+ return 0
+}
+
+while wait_net; do
+ sleep 1
+done
+
+[[ $# > 0 ]] && exec "$@"
+exec /bin/bash -l