5af3a5b8057df6b8f75b9ac162cc77fefde189d4
[openwrt/openwrt.git] / target / linux / ipq806x / base-files / etc / hotplug.d / ieee80211 / 10_fix_wifi_mac
1 #!/bin/ash
2
3 [ "$ACTION" == "add" ] || exit 0
4
5 PHYNBR=${DEVPATH##*/phy}
6
7 [ -n $PHYNBR ] || exit 0
8
9 . /lib/functions.sh
10 . /lib/functions/system.sh
11
12 board=$(board_name)
13
14 case "$board" in
15 ubnt,unifi-ac-hd)
16 macaddr_add $(mtd_get_mac_binary EEPROM 0x6) $(($PHYNBR + 1)) > /sys${DEVPATH}/macaddress
17 ;;
18 esac
19
20 OPATH=${DEVPATH##/devices/platform/}
21 OPATH=${OPATH%%/ieee*}
22
23 # 10 radios is enough for anyone!
24 for i in $(seq 0 9);
25 do
26 BUS=$(uci get wireless.@wifi-device[$i].path)
27 if [ "$BUS " == "$OPATH " ]
28 then
29 PHYNAME=${DEVPATH##*ieee80211/}
30 NPHYNAME=$(uci get wireless.@wifi-device[$i].phyname)
31 if [ "$NPHYNAME " != " " ]
32 then
33 if [ "$PHYNAME " != "$NPHYNAME " ]
34 then
35 iw $PHYNAME set name $NPHYNAME
36 fi
37 fi
38 fi
39 done