3 # This file handles the NVRAM quirks of various hardware.
5 . /etc/network.overrides
6 alias debug=${DEBUG:-:}
9 for type in lan wifi wan pppoe
13 eval nvram set ${type}_ifname$s=\"$(nvram get ${type}_ifname$s|sed s/$1/$2/g)\"
19 [ -z "$(nvram get $1)" ] && nvram set "$1=$2"
22 # linksys bug; remove when not using static configuration for lan
23 nvram set lan_proto="static"
25 # hacks for wrt54g 1.x hardware
26 [ "$(nvram get boardnum)" = "42" \
27 -a "$(nvram get boardtype)" = "bcm94710dev" ] && {
28 debug "### wrt54g 1.x hack ###"
29 nvram set vlan1hwname="et0"
30 nvram set vlan2hwname="et0"
35 # hacks for asus wl-500g deluxe
36 [ "$(nvram get boardtype)" = "bcm95365r" \
37 -a "$(nvram get boardnum)" = "45" ] && {
38 debug "### wl-500g deluxe hacks ###"
39 nvram set vlan0hwname="et0"
40 nvram set vlan1hwname="et0"
44 # set up the vlan*ports variables for the asus wl-500g deluxe
45 # if they don't already exist
46 nvram_default vlan0ports "1 2 3 4 5*"
47 nvram_default vlan1ports "0 5"
50 # hacks for asus wl-300g
51 [ "$(nvram get productid)" = "WL300g" ] && {
52 debug "### wl-300g hacks ###"
53 nvram set lan_ifnames="eth0 eth2"
54 nvram set wan_ifname="none"
57 # hacks for asus wl-hdd
58 [ "$(nvram get productid)" = "WLHDD" ] && {
59 debug "### wl-hdd hacks ###"
60 nvram set lan_ifnames="eth1 eth2"
61 nvram set wan_ifname="none"
64 # hacks for wap54g hardware
65 [ "$(nvram get boardnum)" = "2" \
66 -o "$(nvram get boardnum)" = "1024" ] && {
67 debug "### wap54g hack ###"
68 nvram set wan_ifname="none"
71 # hacks for buffalo wla2-g54l
72 [ "$(nvram get boardnum)" = "00" \
73 -a "$(nvram get product_name)" = "Product_name" \
74 -o "$(nvram get product_name)" = "WLA2-G54L" ] && {
75 debug "### wla2-g54l hacks ###"
76 nvram set wan_ifname="none"
77 nvram set lan_ifnames="vlan0"
80 # needed at least for wrt54gs v1.1 and wrt54g v2.0, v2.2
81 [ \! -z "$(nvram get boardrev)" ] && {
82 nvram set wl0id=0x4320
86 nvram_default lan_ifname "br0"
87 nvram_default lan_ifnames "$FAILSAFE_ifnames"
89 nvram_default wan_ifname "vlan1"
90 nvram_default wan_proto "dhcp"
92 nvram_default wl0_ssid OpenWrt
93 nvram_default wl0_mode ap
94 nvram_default wl0_infra 1
95 nvram_default wl0_radio 1
97 [ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
98 # if default wifi mac, set two higher than the lan mac
99 nvram set il0macaddr=$(nvram get et0macaddr|
100 awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')