blob: 93cd08a08f9c1f306592af800dacfe1e6fb78379 [file] [log] [blame]
Amit Pundire721f612023-11-22 10:37:16 +05301#! /vendor/bin/sh
Amit Pundire0b877a2023-07-19 10:17:38 +05302# Set eth0 mac address.
3#
4# Get the unique board serial number from /proc/cmdline or
5# /proc/bootconfig, prepend '0's to the serial number to
6# fill 5 LSBs of the MAC address and prepend "02" as MSB to
7# prepare a 6 byte locally administered unicast MAC address.
8#
9# Format the output in xx:xx:xx:xx:xx:xx format for the "ip"
10# set address command to work.
11
Amit Pundire721f612023-11-22 10:37:16 +053012ETHADDR=`/vendor/bin/cat /proc/cmdline | /vendor/bin/grep -o serialno.* |\
13 /vendor/bin/cut -f2 -d'=' | /vendor/bin/awk '{printf("02%010s\n", $1)}' |\
14 /vendor/bin/sed 's/\(..\)/\1:/g' | /vendor/bin/sed '$s/:$//'`
Amit Pundire0b877a2023-07-19 10:17:38 +053015if [ -z "${ETHADDR}" ]
16then
Amit Pundire721f612023-11-22 10:37:16 +053017 ETHADDR=`/vendor/bin/cat /proc/bootconfig | /vendor/bin/grep -o serialno.* |\
18 /vendor/bin/cut -f2 -d'=' | /vendor/bin/cut -c 3-10 |\
19 /vendor/bin/awk '{printf("02%010s\n", $1)}' |\
20 /vendor/bin/sed 's/\(..\)/\1:/g' | /vendor/bin/sed '$s/:$//'`
Amit Pundire0b877a2023-07-19 10:17:38 +053021fi
22
Amit Pundire721f612023-11-22 10:37:16 +053023/vendor/bin/ifconfig eth0 down
24/vendor/bin/ifconfig eth0 hw ether "${ETHADDR}"
25/vendor/bin/ifconfig eth0 up