diff --git a/app/client/start-https.sh b/app/client/start-https.sh index 626bafb919..f8fa9d0c06 100755 --- a/app/client/start-https.sh +++ b/app/client/start-https.sh @@ -63,24 +63,18 @@ client_proxy_pass="${default_client_proxy}" network_mode="bridge" case "${uname_out}" in Linux*) machine=Linux - - proc_version="$(cat /proc/version)" - case "$proc_version" in - *icrosoft*) + + source ../util/is_wsl.sh + if [ $IS_WSL ]; then # ignore to continue using host.docker.internal - ;; - *WSL*) - # ignore to continue using host.docker.internal - ;; - *) + else network_mode="host" client_proxy_pass=$default_linux_client_proxy # if no server was passed if [[ -z $1 ]]; then server_proxy_pass=$default_linux_server_proxy fi - ;; - esac + fi echo " Starting nginx for Linux... " diff --git a/app/server/scripts/start-dev-server.sh b/app/server/scripts/start-dev-server.sh index 9e1ec6324c..66a9c753e6 100755 --- a/app/server/scripts/start-dev-server.sh +++ b/app/server/scripts/start-dev-server.sh @@ -10,4 +10,9 @@ if [[ -f .env ]]; then source .env fi +source ../util/is_wsl.sh +if [ $IS_WSL ]; then + _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true $_JAVA_OPTIONS" +fi + (cd dist && exec java -jar server-*.jar) diff --git a/app/util/is_wsl.sh b/app/util/is_wsl.sh new file mode 100755 index 0000000000..ee100634c0 --- /dev/null +++ b/app/util/is_wsl.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +IS_WSL= + +proc_version="$(cat /proc/version)" +case "$proc_version" in +*icrosoft*) + IS_WSL=true +;; +*WSL*) + IS_WSL=true +;; +esac diff --git a/app/util/is_wsl_test.sh b/app/util/is_wsl_test.sh new file mode 100755 index 0000000000..ba97288f68 --- /dev/null +++ b/app/util/is_wsl_test.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -e + +DIR="$(cd "$(dirname "$0")" && pwd)" + +distro= + +cat() { + echo $distro +} + +fail() { + local reason=$1 + + echo "${reason} + context: ${distro}" + + exit 1 +} + +stub_distro() { + local name=$1 + + distro=$name + source $DIR/is_wsl.sh +} + +stub_distro "Linux Computer 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux" +if [ ! $IS_WSL ]; then + fail "Failed: Detected lack of WSL where it should have." +fi + +stub_distro "Linux Computer 4.19.104-WSL-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux" +if [ ! $IS_WSL ]; then + fail "Failed: Detected lack of WSL where it should have." +fi + +stub_distro "Linux pop-os 5.3.0-22-generic #24+system76~1573659475~19.04~26b2022-Ubuntu SMP Wed Nov 13 20:0 x86_64 x86_64 x86_64 GNU/Linux" +if [ $IS_WSL ]; then + fail "Failed: Detected WSL where it shouldn't have." +fi + +echo "All Tests Pass!"