|
|
@@ -1,23 +1,19 @@
|
|
|
# Copyright (C) 2018 OpenWrt.org
|
|
|
|
|
|
-RECOVERY_PART=/dev/mmcblk0p1
|
|
|
+. /lib/functions.sh
|
|
|
+. /lib/functions/system.sh
|
|
|
|
|
|
-preinit_set_mac_address() {
|
|
|
+set_recovery_mac_address() {
|
|
|
+ local RECOVERY_PART="$1"
|
|
|
local mac
|
|
|
|
|
|
- . /lib/functions.sh
|
|
|
- . /lib/functions/system.sh
|
|
|
-
|
|
|
- case $(board_name) in
|
|
|
- unielec,u7623-02-emmc-512m)
|
|
|
- if [ -b $RECOVERY_PART ]; then
|
|
|
- insmod nls_cp437
|
|
|
- insmod nls_iso8859-1
|
|
|
- insmod fat
|
|
|
- insmod vfat
|
|
|
- mkdir -p /tmp/recovery
|
|
|
- mount -o rw,noatime $RECOVERY_PART /tmp/recovery
|
|
|
-
|
|
|
+ if [ -b $RECOVERY_PART ]; then
|
|
|
+ insmod nls_cp437
|
|
|
+ insmod nls_iso8859-1
|
|
|
+ insmod fat
|
|
|
+ insmod vfat
|
|
|
+ mkdir -p /tmp/recovery
|
|
|
+ if mount -o rw,noatime $RECOVERY_PART -t vfat /tmp/recovery; then
|
|
|
if [ -f "/tmp/recovery/mac_addr" ];
|
|
|
then
|
|
|
mac=$(cat /tmp/recovery/mac_addr)
|
|
|
@@ -28,17 +24,34 @@ preinit_set_mac_address() {
|
|
|
|
|
|
sync
|
|
|
umount /tmp/recovery
|
|
|
- rm -rf /tmp/recovery
|
|
|
- fi
|
|
|
+ rmdir /tmp/recovery
|
|
|
|
|
|
- ip link set dev wan address $mac 2> /dev/null
|
|
|
+ ip link set dev wan address $mac 2> /dev/null
|
|
|
|
|
|
- mac=$(macaddr_add $mac 1)
|
|
|
+ mac=$(macaddr_add $mac 1)
|
|
|
|
|
|
- ip link set dev lan0 address $mac 2>/dev/null
|
|
|
- ip link set dev lan1 address $mac 2>/dev/null
|
|
|
- ip link set dev lan2 address $mac 2>/dev/null
|
|
|
- ip link set dev lan3 address $mac 2>/dev/null
|
|
|
+ ip link set dev lan0 address $mac 2>/dev/null
|
|
|
+ ip link set dev lan1 address $mac 2>/dev/null
|
|
|
+ ip link set dev lan2 address $mac 2>/dev/null
|
|
|
+ ip link set dev lan3 address $mac 2>/dev/null
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+preinit_set_mac_address() {
|
|
|
+ local rootpart
|
|
|
+
|
|
|
+ case $(board_name) in
|
|
|
+ bananapi,bpi-r2)
|
|
|
+ rootpart=$(cat /proc/cmdline)
|
|
|
+ rootpart="${rootpart##*root=}"
|
|
|
+ rootpart="${rootpart%%p3 *}"
|
|
|
+ if [ "$rootpart" = "/dev/mmcblk0" -o "$rootpart" = "/dev/mmcblk1" ]; then
|
|
|
+ set_recovery_mac_address ${rootpart}p2
|
|
|
+ fi
|
|
|
+ ;;
|
|
|
+ unielec,u7623-02-emmc-512m)
|
|
|
+ set_recovery_mac_address /dev/mmcblk0p1
|
|
|
;;
|
|
|
esac
|
|
|
}
|