Amit Pundir | 7cc6a2d | 2020-04-23 21:39:03 +0530 | [diff] [blame] | 1 | #! /system/bin/sh |
| 2 | # Set eth0 mac address. |
| 3 | # |
| 4 | # Get the unique board serial number from /proc/cmdline, |
| 5 | # prepend '0's to the serial number to fill 5 LSBs of the |
| 6 | # MAC address and prepend "02" as MSB to prepare a 6 byte |
| 7 | # locally administered unicast MAC address. |
| 8 | # Format the output in xx:xx:xx:xx:xx:xx format for the |
| 9 | # "ip" set address command to work. |
| 10 | |
| 11 | SERIALNO=`cat /proc/cmdline | grep -o serialno.* | cut -f2 -d'=' | awk '{printf("02%010s\n", $1)}' | sed 's/\(..\)/\1:/g' | sed '$s/:$//'` |
| 12 | |
| 13 | /system/bin/ip link set dev eth0 down |
| 14 | /system/bin/ip link set dev eth0 address "${SERIALNO}" |
| 15 | /system/bin/ip link set dev eth0 up |