blob: 2bfa8d8d56b0414add086146483c2957c621a94e [file] [log] [blame]
Amit Pundire0b877a2023-07-19 10:17:38 +05301#! /system/bin/sh
2# 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
12ETHADDR=`cat /proc/cmdline | grep -o serialno.* | cut -f2 -d'=' |\
13 awk '{printf("02%010s\n", $1)}' | sed 's/\(..\)/\1:/g' |\
14 sed '$s/:$//'`
15if [ -z "${ETHADDR}" ]
16then
17ETHADDR=`cat /proc/bootconfig | grep -o serialno.* |\
18 cut -f2 -d'=' | cut -c 3-10 |\
19 awk '{printf("02%010s\n", $1)}' | sed 's/\(..\)/\1:/g' |\
20 sed '$s/:$//'`
21fi
22
23ip link set dev eth0 down
24ip link set dev eth0 address "${ETHADDR}"
25ip link set dev eth0 up