Skip to content

Commit

Permalink
feat: Persistant MAC address (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese committed Feb 28, 2024
1 parent 8652544 commit 5896928
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,14 @@ getInfo() {
fi

if [ -z "$VM_NET_MAC" ]; then
# Generate MAC address based on Docker container ID in hostname
VM_NET_MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:11:32:\3:\4:\5/')
local file="$STORAGE/dsm.mac"
if [ -f "$file" ]; then
VM_NET_MAC=$(<"$file")
else
# Generate MAC address based on Docker container ID in hostname
VM_NET_MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:11:32:\3:\4:\5/')
echo "${VM_NET_MAC^^}" > "$file"
fi
fi

VM_NET_MAC="${VM_NET_MAC^^}"
Expand Down

0 comments on commit 5896928

Please sign in to comment.