Amit Pundir | e721f61 | 2023-11-22 10:37:16 +0530 | [diff] [blame^] | 1 | #! /vendor/bin/sh |
Amit Pundir | e0b877a | 2023-07-19 10:17:38 +0530 | [diff] [blame] | 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 | |
Amit Pundir | e721f61 | 2023-11-22 10:37:16 +0530 | [diff] [blame^] | 12 | ETHADDR=`/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 Pundir | e0b877a | 2023-07-19 10:17:38 +0530 | [diff] [blame] | 15 | if [ -z "${ETHADDR}" ] |
| 16 | then |
Amit Pundir | e721f61 | 2023-11-22 10:37:16 +0530 | [diff] [blame^] | 17 | 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 Pundir | e0b877a | 2023-07-19 10:17:38 +0530 | [diff] [blame] | 21 | fi |
| 22 | |
Amit Pundir | e721f61 | 2023-11-22 10:37:16 +0530 | [diff] [blame^] | 23 | /vendor/bin/ifconfig eth0 down |
| 24 | /vendor/bin/ifconfig eth0 hw ether "${ETHADDR}" |
| 25 | /vendor/bin/ifconfig eth0 up |