rename target/linux/package/openwrt to base-files
[openwrt.git] / target / linux / package / base-files / files / brcm-2.4 / etc / init.d / S05nvram
1 # NVRAM setup
2 #
3 # This file handles the NVRAM quirks of various hardware.
4
5 . /etc/network.overrides
6 alias debug=${DEBUG:-:}
7
8 remap () {
9 for type in lan wifi wan pppoe
10 do
11 for s in '' s
12 do
13 eval nvram set ${type}_ifname$s=\"$(nvram get ${type}_ifname$s|sed s/$1/$2/g)\"
14 done
15 done
16 }
17
18 nvram_default() {
19 [ -z "$(nvram get $1)" ] && nvram set "$1=$2"
20 }
21
22 # linksys bug; remove when not using static configuration for lan
23 nvram set lan_proto="static"
24
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"
31 remap eth0 vlan2
32 remap eth1 vlan1
33 }
34
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"
41 remap eth0.1 vlan0
42 remap eth0 vlan1
43
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"
48 }
49
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"
55 }
56
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"
62 }
63
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"
69 }
70
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"
78 }
79
80 # needed at least for wrt54gs v1.1 and wrt54g v2.0, v2.2
81 [ \! -z "$(nvram get boardrev)" ] && {
82 nvram set wl0id=0x4320
83 }
84
85 # defaults
86 nvram_default lan_ifname "br0"
87 nvram_default lan_ifnames "$FAILSAFE_ifnames"
88
89 nvram_default wan_ifname "vlan1"
90 nvram_default wan_proto "dhcp"
91
92 nvram_default wl0_ssid OpenWrt
93 nvram_default wl0_mode ap
94 nvram_default wl0_infra 1
95 nvram_default wl0_radio 1
96
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}')
101 }
102
This page took 0.040819 seconds and 5 git commands to generate.