baf4a20721996412bdce9171993d66d4cac933ae
[openwrt/openwrt.git] / target / linux / mvebu / base-files / etc / uci-defaults / 03_wireless
1 #!/bin/sh
2 #
3 # Copyright (C) 2015 OpenWrt.org
4 #
5
6 [ ! -e /etc/config/wireless ] && exit 0
7
8 . /lib/functions.sh
9 . /lib/functions/system.sh
10
11 board=$(board_name)
12
13 case "$board" in
14 armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby|armada-xp-linksys-mamba)
15 SKU=$(strings /dev/mtd3|sed -ne 's/^cert_region=//p')
16 WIFIMAC2G=$(macaddr_add $(cat /sys/class/net/eth0/address) +1)
17 WIFIMAC5G=$(macaddr_add $WIFIMAC2G +1)
18 case "$SKU" in
19 AP)
20 REGD=CN
21 ;;
22 AU)
23 REGD=AU
24 ;;
25 CA)
26 REGD=CA
27 ;;
28 EU)
29 REGD=DE
30 ;;
31 US)
32 REGD=US
33 ;;
34 esac
35
36 case "$board" in
37 armada-xp-linksys-mamba)
38 WIFIMAC0=$WIFIMAC2G
39 WIFIMAC1=$WIFIMAC5G
40 ;;
41 *)
42 WIFIMAC0=$WIFIMAC5G
43 WIFIMAC1=$WIFIMAC2G
44 ;;
45 esac
46
47 uci get wireless.radio0.country || uci set wireless.radio0.country=$REGD
48 uci get wireless.@wifi-iface[0].macaddr || uci set wireless.@wifi-iface[0].macaddr=$WIFIMAC0
49 uci get wireless.radio1.country || uci set wireless.radio1.country=$REGD
50 uci get wireless.@wifi-iface[1].macaddr || uci set wireless.@wifi-iface[1].macaddr=$WIFIMAC1
51 ;;
52 esac
53
54 uci commit wireless
55
56 exit 0