mcdan commented on a change in pull request #77: Fixes a few linux issues with
the makefile
URL:
https://github.com/apache/incubator-openwhisk-devtools/pull/77#discussion_r160177883
##########
File path: docker-compose/Makefile
##########
@@ -1,8 +1,14 @@
+UNAME_STR ?= $(shell uname)
+
# detect local ip of host as this is needed within containers to find the
openwhisk API container
-LOCAL_IP ?= $(shell ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\ -f2
| head -1)
-# if no IP was found, fallback to "localhost"
-ifeq ($(LOCAL_IP), )
- LOCAL_IP = "localhost"
+ifeq ("$(UNAME_STR)","Linux")
+ LOCAL_IP=$(shell route | grep default | tr -s " " | cut -d " " -f 8 |
xargs ifconfig | grep "inet addr:" | cut -d ":" -f 2 | cut -d " " -f 1)
+else
+ LOCAL_IP ?= $(shell ifconfig | grep "inet " | grep -v 127.0.0.1 | cut
-d\ -f2 | head -1)
Review comment:
On my Ubuntu machine the above command produces an empty string as the
result. "cut -d\ -f2 " returning a list of empty strings. The input to that
pipe on my machine is:
```bash
inet addr:172.18.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet addr:10.32.65.11 Bcast:10.32.65.255 Mask:255.255.254.0
```
So no matter how you much the first line here you're going to get the wrong
adapter.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services