feat: Persistant MAC address (#30)

This commit is contained in:
Kroese 2024-02-28 08:16:22 +01:00 committed by GitHub
parent 8c6e9d3d7b
commit 74674eab18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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