From 67b8890b1e8dd107e136aeb7cbd3e78b49bf52e6 Mon Sep 17 00:00:00 2001 From: mviereck Date: Sun, 20 Jan 2019 02:45:22 +0100 Subject: [PATCH] Fix IP check on Windows #102 --- CHANGELOG.md | 3 +++ x11docker | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67df3f16..a27bf2b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ Project website: https://github.com/mviereck/x11docker - Add `-nolisten local` to X commands to forbid abstract socket connections. ### Fixed - `-t, --tty`: Long option was not parsed. + - Fixed IP check on MS Windows + [(#102)](https://github.com/mviereck/x11docker/issues/102) + ## [5.3.3](https://github.com/mviereck/x11docker/releases/tag/v5.3.3) - 2018-11-17 ### Added diff --git a/x11docker b/x11docker index 4786386d..79fcee9c 100755 --- a/x11docker +++ b/x11docker @@ -5094,15 +5094,6 @@ check_host() { # check host environment } || { Hostutctime="UTC+$(cut -c2- <<< "$Hostutctime")" } - - # Check host IP. Needed for --pulseaudio=tcp, --vcxsrv and --xwin - case $Winsubsystem in - "") Hostip="$(ip -4 -o a | grep 'docker0' | awk '{print $4}' | cut -d/ -f1)" - [ "$Hostip" ] || Hostip="$(ip -4 -o a | awk '{print $4}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -n1)" ;; - *) Hostip="$(ipconfig.exe | grep -A6 'DockerNAT' | grep 'IPv4' | rev | cut -d' ' -f1 | rev)" - [ "$Hostip" ] || Hostip="$(ipconfig.exe | grep 'IPv4' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | grep "^10\.0\.*" )" - [ "$Hostip" ] || Hostip="$(ipconfig.exe | grep 'IPv4' | head -n1 | | rev | cut -d' ' -f1 | rev)" ;; - esac # Check for MS Windows subsystem uname -r | grep -q Microsoft && Winsubsystem="WSL" @@ -5125,6 +5116,15 @@ check_host() { # check host environment Hostsystem="Windows-$Winsubsystem" } + # Check host IP. Needed for --pulseaudio=tcp, --vcxsrv and --xwin + case $Winsubsystem in + "") Hostip="$(ip -4 -o a | grep 'docker0' | awk '{print $4}' | cut -d/ -f1)" + [ "$Hostip" ] || Hostip="$(ip -4 -o a | awk '{print $4}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -n1)" ;; + *) Hostip="$(ipconfig.exe | grep -A6 'DockerNAT' | grep 'IPv4' | rev | cut -d' ' -f1 | rev)" + [ "$Hostip" ] || Hostip="$(ipconfig.exe | grep 'IPv4' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | grep "^10\.0\.*" )" + [ "$Hostip" ] || Hostip="$(ipconfig.exe | grep 'IPv4' | head -n1 | | rev | cut -d' ' -f1 | rev)" ;; + esac + # Provide dos->unix newline converter to $Mksu commands export -f rmcr