Skip to content

Commit

Permalink
feat: Detect Docker Desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored May 11, 2024
1 parent 586be3b commit 51d5526
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,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, please revert to bridge networking!"
return 1
fi

return 0
}

getInfo() {

if [ -z "$VM_NET_DEV" ]; then
Expand Down Expand Up @@ -305,6 +322,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
Expand All @@ -314,6 +333,10 @@ if [[ "$DHCP" == [Yy1]* ]]; then

else

if [[ "$GATEWAY" != "172."* ]]; then
! checkOS && exit 19
fi

# Configuration for static IP
configureNAT

Expand Down

0 comments on commit 51d5526

Please sign in to comment.