29 lines
653 B
Bash
Executable File
29 lines
653 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
|
TINCRC="$DIR/tincrc"
|
|
MAC_ADDRESS=""
|
|
|
|
if [ -f "$TINCRC" ]; then
|
|
source "$TINCRC"
|
|
else
|
|
export MAC_ADDRESS=""
|
|
fi
|
|
|
|
if [[ -n "$MAC_ADDRESS" ]]; then
|
|
echo "Skip generating MAC: MAC_ADDRESS with value '$MAC_ADDRESS' already defined in '$TINCRC'."
|
|
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 'export MAC_ADDRESS=02:1F:%02X:%02X:%02X:%02X\n' \
|
|
$[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] \
|
|
| tee -a "$TINCRC"
|
|
fi
|