1 # Copyright (C) 2018 OpenWrt.org
4 . /lib/functions/system.sh
6 set_recovery_mac_address() {
7 local RECOVERY_PART="$1"
10 if [ -b $RECOVERY_PART ]; then
15 mkdir -p /tmp/recovery
16 if mount -o rw,noatime $RECOVERY_PART -t vfat /tmp/recovery; then
17 if [ -f "/tmp/recovery/mac_addr" ];
19 mac=$(cat /tmp/recovery/mac_addr)
21 mac=$(cat /sys/class/net/eth0/address)
22 echo "$mac" > /tmp/recovery/mac_addr
29 ip link set dev wan address $mac 2> /dev/null
31 mac=$(macaddr_add $mac 1)
33 ip link set dev lan0 address $mac 2>/dev/null
34 ip link set dev lan1 address $mac 2>/dev/null
35 ip link set dev lan2 address $mac 2>/dev/null
36 ip link set dev lan3 address $mac 2>/dev/null
41 preinit_set_mac_address() {
46 rootpart=$(cat /proc/cmdline)
47 rootpart="${rootpart##*root=}"
48 rootpart="${rootpart%%p3 *}"
49 if [ "$rootpart" = "/dev/mmcblk0" -o "$rootpart" = "/dev/mmcblk1" ]; then
50 set_recovery_mac_address ${rootpart}p2
53 unielec,u7623-02-emmc-512m)
54 set_recovery_mac_address /dev/mmcblk0p1
59 boot_hook_add preinit_main preinit_set_mac_address