From 46b8ecdf762afe5c0eff502502f1b1eee49366b0 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 11 May 2024 21:15:46 +0200 Subject: [PATCH 1/4] feat: Detect Windows and MacOS --- src/network.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/network.sh b/src/network.sh index c553501d..69ed5119 100644 --- a/src/network.sh +++ b/src/network.sh @@ -240,6 +240,23 @@ closeNetwork() { return 0 } +checkOS() { + + local name + local os="" + name=$(uname -a) + + [[ "${name,,}" == *"darwin"* ]] && os="MacOS" + [[ "${name,,}" == *"microsoft"* ]] && os="Windows" + + if [ -n "$os" ]; then + error "You are using Docker Desktop for $os, which does not support macvlan!" + return 1 + fi + + return 0 +} + getInfo() { if [ -z "$VM_NET_DEV" ]; then @@ -306,6 +323,8 @@ fi if [[ "$DHCP" == [Yy1]* ]]; then + ! checkOS && exit 19 + if [[ "$GATEWAY" == "172."* ]]; then warn "your gateway IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!" fi @@ -318,6 +337,10 @@ if [[ "$DHCP" == [Yy1]* ]]; then else + if [[ "$GATEWAY" != "172."* ]]; then + ! checkOS && exit 19 + fi + # Shutdown nginx nginx -s stop 2> /dev/null fWait "nginx" From f0ee63c201a994d2dfc534ca9d66152a72d7ecee Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 11 May 2024 21:18:00 +0200 Subject: [PATCH 2/4] Update network.sh --- src/network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network.sh b/src/network.sh index 69ed5119..c54b6818 100644 --- a/src/network.sh +++ b/src/network.sh @@ -250,7 +250,7 @@ checkOS() { [[ "${name,,}" == *"microsoft"* ]] && os="Windows" if [ -n "$os" ]; then - error "You are using Docker Desktop for $os, which does not support macvlan!" + error "You are using Docker Desktop for $os which does not support macvlan, please revert to bridge networking!" return 1 fi From cd296b6e85333a7a3c01aba64777c845d23a0059 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 11 May 2024 21:30:25 +0200 Subject: [PATCH 3/4] feat: Detect MacOS --- src/proc.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/proc.sh b/src/proc.sh index a8b02543..52e08310 100644 --- a/src/proc.sh +++ b/src/proc.sh @@ -30,9 +30,13 @@ if [[ "$KVM" != [Nn]* ]]; then if [ -n "$KVM_ERR" ]; then KVM="N" - error "KVM acceleration not available $KVM_ERR, this will cause a major loss of performance." - error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)." - [[ "$DEBUG" != [Yy1]* ]] && exit 88 + if [[ "$OSTYPE" =~ ^darwin ]]; then + warn "you are using MacOS which has no KVM support, this will cause a major loss of performance." + else + error "KVM acceleration not available $KVM_ERR, this will cause a major loss of performance." + error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)." + [[ "$DEBUG" != [Yy1]* ]] && exit 88 + fi fi fi From b23aaa3250ce6343477716cf74a61ff772819d94 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 11 May 2024 22:08:57 +0200 Subject: [PATCH 4/4] feat: Detect Docker for Windows --- src/proc.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/proc.sh b/src/proc.sh index 52e08310..fca56139 100644 --- a/src/proc.sh +++ b/src/proc.sh @@ -33,9 +33,13 @@ if [[ "$KVM" != [Nn]* ]]; then if [[ "$OSTYPE" =~ ^darwin ]]; then warn "you are using MacOS which has no KVM support, this will cause a major loss of performance." else - error "KVM acceleration not available $KVM_ERR, this will cause a major loss of performance." - error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)." - [[ "$DEBUG" != [Yy1]* ]] && exit 88 + if grep -qi Microsoft /proc/version; then + warn "you are using Windows 10 which has no KVM support, this will cause a major loss of performance." + else + error "KVM acceleration not available $KVM_ERR, this will cause a major loss of performance." + error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)." + [[ "$DEBUG" != [Yy1]* ]] && exit 88 + fi fi fi