Ver Fonte

get-host-ip use docker network instead of ip command

Mokhtar Naamani há 3 anos atrás
pai
commit
23ff1871d6
1 ficheiros alterados com 5 adições e 4 exclusões
  1. 5 4
      tests/network-tests/get-host-ip.sh

+ 5 - 4
tests/network-tests/get-host-ip.sh

@@ -2,13 +2,14 @@
 set -e
 
 if [[ "$OSTYPE" == "linux-gnu" ]]; then
-    # We could get the specific network address for the docker network with
-    #   docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' joystream_default
-    ip route | awk '/default/ {print $3}'
+    docker network inspect --format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' joystream_default
 elif [[ "$OSTYPE" == "darwin"* ]]; then
     # try en0 if not set then en1 (Wired or Wireless)
     ipconfig getifaddr en0 || ipconfig getifaddr en1
+else
+    echo 'localhost'
 fi
 
 # Some alternative approaches (cross platform)
-# ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
+# ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
+# ip route | awk '/default/ {print $3}'