feat: Detect Windows and MacOS

This commit is contained in:
Kroese 2024-05-11 21:15:46 +02:00 committed by GitHub
parent c86408cbd6
commit 46b8ecdf76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"