diff --git a/dockerfiles/rsync-copy/Dockerfile b/dockerfiles/rsync-copy/Dockerfile index ac20e5d..7c5e627 100644 --- a/dockerfiles/rsync-copy/Dockerfile +++ b/dockerfiles/rsync-copy/Dockerfile @@ -26,7 +26,7 @@ ENV SOURCE_URL= \ KEEP_SOURCE_FILE=yes \ SERVER_CONTAINERIZED= -COPY check.sh parse.sh run.sh /app/bin/ +COPY parse.sh run.sh /app/bin/ COPY --from=hub.cstcloud.cn/scalebox/base /usr/local/sbin/ /usr/local/sbin/ RUN mkdir -p /work/.scalebox /app/bin && echo "PATH=/app/bin:\${PATH}" >> /root/.bashrc diff --git a/golang/misc/net.go b/golang/misc/net.go index d42a6d2..fec469e 100644 --- a/golang/misc/net.go +++ b/golang/misc/net.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "regexp" + "runtime" "strings" "github.com/sirupsen/logrus" @@ -19,7 +20,10 @@ func GetLocalIP() string { var cmd string if localIPIndexStr == "" { cmd = "hostname -i" - } else { + } else if runtime.GOOS == "darwin" { // macos + // 172.*.*.* are used for out-of-band Network/container network + cmd = `ifconfig|grep "inet "|grep -v 127.0.0.1|grep -v "inet 172."|head -1|cut -d ' ' -f 2` + } else { // linux cmd = fmt.Sprintf("hostname -I | awk '{print $%s}'", localIPIndexStr) } diff --git a/server/Makefile b/server/Makefile index 1bc52bd..e399947 100644 --- a/server/Makefile +++ b/server/Makefile @@ -19,7 +19,7 @@ ifeq ($(origin LOCAL_ADDR), undefined) LOCAL_ADDR := $$(hostname -I| cut -d ' ' -f ${LOCAL_IP_INDEX}) endif else ifeq ($(UNAME), Darwin) - LOCAL_ADDR := $$(ifconfig|grep "inet "|grep -v 127.0.0.1|head -1|cut -d ' ' -f 2) + LOCAL_ADDR := $$(ifconfig|grep "inet "|grep -v 127.0.0.1|grep -v "inet 172."|head -1|cut -d ' ' -f 2) else $(info This is neither a Linux nor a macOS system) endif