bin/network-init-recovery: generate random MAC and set it to eth0

network-init-reovery can be used to automatically set RTC clock to obtained NTP clock.
The script would fail if other devices devices previously registered on the network with the same MAC.
Consequently, maximized boards are detected here, and a full random MAC is generated and used instead of using hardcoded DE:AD:C0:FF:EE.
This commit is contained in:
Thierry Laurion 2022-04-29 10:26:02 -04:00
parent 37a343a49c
commit e60287fa1d
No known key found for this signature in database
GPG Key ID: E7B4A71658E36A93

View File

@ -1,5 +1,7 @@
#!/bin/ash
. /etc/functions
# bring up the ethernet; maybe should do DHCP?
ifconfig lo 127.0.0.1
@ -11,6 +13,16 @@ for module in `echo $network_modules`; do
done
if [ -e /sys/class/net/eth0 ]; then
#Randomize eth0 MAC address of maximized boards
if echo "$CONFIG_BOARD" | grep -q maximized; then
ifconfig eth0 down
echo "Generating random MAC address (might take a while)..."
mac=$(generate_random_mac_address)
echo "Assigning randomly generated MAC: $mac to eth0..."
ifconfig eth0 hw ether $mac
ifconfig eth0 up
fi
# Set up static IP
if [ ! -z "$CONFIG_BOOT_STATIC_IP" ]; then
ifconfig eth0 $CONFIG_BOOT_STATIC_IP