feat: Persistant MAC address (#646)

This commit is contained in:
Kroese 2024-02-28 08:40:00 +01:00 committed by GitHub
parent 8652544982
commit 5896928030
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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