hotplug: Allow configuring radio name.
[oweals/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         linksys,ea8500)
16                 echo $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
17                 ;;
18         nec,wg2600hp)
19                 echo $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 12) $((1 - $PHYNBR)) ) > /sys${DEVPATH}/macaddress
20                 ;;
21         netgear,d7800 |\
22         netgear,r7500v2 |\
23         netgear,r7800)
24                 echo $(macaddr_add $(mtd_get_mac_binary art 6)  $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
25                 ;;
26         tplink,c2600)
27                 echo $(macaddr_add $(mtd_get_mac_binary default-mac 8)  $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
28                 ;;
29         tplink,vr2600v)
30                 echo $(macaddr_add $(mtd_get_mac_binary default-mac 0)  $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
31                 ;;
32         zyxel,nbg6817)
33                 echo $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) $((1 - $PHYNBR)) ) > /sys${DEVPATH}/macaddress
34                 ;;
35         *)
36                 ;;
37 esac
38
39 OPATH=${DEVPATH##/devices/platform/}
40 OPATH=${OPATH%%/ieee*}
41
42 # 10 radios is enough for anyone!
43 for i in `seq 0 9`;
44   do
45   BUS=`uci get wireless.@wifi-device[$i].path`
46   if [ "$BUS " == "$OPATH " ]
47       then
48       PHYNAME=${DEVPATH##*ieee80211/}
49       NPHYNAME=`uci get wireless.@wifi-device[$i].phyname`
50       if [ "$NPHYNAME " != " " ]
51           then
52           if [ "$PHYNAME " != "$NPHYNAME " ]
53               then
54               iw $PHYNAME set name $NPHYNAME
55           fi
56       fi
57   fi
58 done