Adds a docker_ip pipeline for /sbin/ip
authorLuke GB <github@lukegb.com>
Sun, 14 Sep 2014 17:31:17 +0000 (18:31 +0100)
committerLuke GB <github@lukegb.com>
Sun, 14 Sep 2014 17:31:17 +0000 (18:31 +0100)
This fixes issues with systems which don't have ifconfig configured and have fully transitioned over to solely using /sbin/ip.

launcher

index ee82bcbd403158ed4d4c4bb2fe63e534e3acede5..055f8d4112a97beb0185dcd80e749065f6a65886 100755 (executable)
--- a/launcher
+++ b/launcher
@@ -16,11 +16,17 @@ local_discourse=local_discourse
 image=samsaffron/discourse:1.0.3
 docker_path=`which docker.io || which docker`
 
-docker_ip=`/sbin/ifconfig | \
-                grep -B1 "inet addr" | \
-                awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' | \
-                grep docker0 | \
-                awk -F: '{ print $3 }';`
+if [ -x /sbin/ip ]; then
+  docker_ip=`/sbin/ip addr show docker0 | \
+                  grep 'inet ' | \
+                  awk '{ split($2,a,"/"); print a[1] }';`
+else
+  docker_ip=`/sbin/ifconfig | \
+                  grep -B1 "inet addr" | \
+                  awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' | \
+                  grep docker0 | \
+                  awk -F: '{ print $3 }';`
+fi
 
 
 usage () {