22 lines
535 B
Plaintext
22 lines
535 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -eu
|
||
|
|
||
|
DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
|
||
|
MACADDR_FILE="$DIR/tinc-macaddr"
|
||
|
if [ -e "$MACADDR_FILE" ]; then
|
||
|
echo "Skip generating MAC: '$MACADDR_FILE' does already exists."
|
||
|
exit 1
|
||
|
else
|
||
|
# Locally Administered Address Ranges:
|
||
|
#x2-xx-xx-xx-xx-xx
|
||
|
#x6-xx-xx-xx-xx-xx
|
||
|
#xA-xx-xx-xx-xx-xx
|
||
|
#xE-xx-xx-xx-xx-xx
|
||
|
# Replacing x with any hex value.
|
||
|
printf '02:1F:%02X:%02X:%02X:%02X\n' \
|
||
|
$[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] \
|
||
|
> "$MACADDR_FILE"
|
||
|
fi
|
||
|
cat $MACADDR_FILE
|