Skip to content

Commit 89f6ec9

Browse files
committed
added check for mirrored WSL2
1 parent 9f334d0 commit 89f6ec9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,31 @@ export DOCKER_REGISTRY ?= itisfoundation
8989

9090
MAKEFILES_WITH_OPENAPI_SPECS := $(shell find . -mindepth 2 -type f -name 'Makefile' -not -path '*/.*' -exec grep -l '^openapi-specs:' {} \; | xargs realpath)
9191

92+
# WSL 2 tricks
93+
define _check_wsl_mirroring
94+
$(shell \
95+
if [ "$(IS_WSL2)" = "WSL2" ]; then \
96+
win_user=$$(powershell.exe '$$env:UserName' | tr -d '\r' | tail -n 1 | xargs); \
97+
config_path="/mnt/c/Users/$$win_user/.wslconfig"; \
98+
if [ -f "$$config_path" ] && grep -q "networkingMode.*=.*mirrored" "$$config_path" 2>/dev/null; then \
99+
echo "true"; \
100+
else \
101+
echo "false"; \
102+
fi; \
103+
else \
104+
echo "false"; \
105+
fi \
106+
)
107+
endef
108+
109+
WSL_MIRRORED := $(_check_wsl_mirroring)
110+
111+
112+
ifeq ($(WSL_MIRRORED),true)
113+
get_my_ip := 127.0.0.1
114+
else
92115
get_my_ip := $(shell (hostname --all-ip-addresses || hostname -i) 2>/dev/null | cut --delimiter=" " --fields=1)
116+
endif
93117

94118
# NOTE: this is only for WSL2 as the WSL2 subsystem IP is changing on each reboot
95119
ifeq ($(IS_WSL2),WSL2)

0 commit comments

Comments
 (0)