1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
7 [ -e /etc
/config
/network
] && exit 0
12 if grep -E 'mtd0: 000(6|a)0000' /proc
/mtd
2>&- >&-; then
14 echo boardtype
=wgt634u
16 strings "$(find_mtd_part nvram)"
19 function p(cfgname, name) {
20 if (c[name] != "") print " option " cfgname " \"" c[name] "\""
23 function vlan(id, name) {
25 print "config switch_vlan eth0_" id
26 print " option device \"eth0\""
27 print " option vlan " id
28 print " option ports \"" c[name] "\""
33 function macinc(mac, maca, i, result) {
35 for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i]
36 if (++maca[6] > 0xff) {
40 for (i = 1; i <= 6; i++) {
41 if (i != 1) result = result ":"
42 result = result sprintf("%02x", maca[i])
49 c["lan_ifname"]="eth0.0"
50 c["wan_ifname"]="eth0.1"
51 c["vlan0ports"]="1 2 3 4 5*"
53 getline < "/proc/diag/model"
55 for (i = 0; i < 6; i++) {
56 if (mac_check != "") mac_check = mac_check ":"
57 mac_check = mac_check "[0-9a-fA-F][0-9a-fA-F]"
61 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") || ($1 ~ /macaddr/) {
66 if ((model == "ASUS WL-HDD") || (model == "ASUS WL-300g") || (model == "Linksys WAP54G V1")) {
68 c["lan_ifname"] = "eth1"
70 if (model == "ASUS WL-330gE") {
72 c["lan_ifname"] = "eth0"
76 if (model == "ASUS WL-500g") {
77 c["wan_ifname"] = "eth1"
78 c["lan_ifname"] = "eth0"
80 if (model == "ASUS WL-500g Premium V2") {
81 c["vlan0ports"] = "0 1 2 3 5*"
82 c["vlan1ports"] = "4 5"
84 if (model == "Dell TrueMobile 2300") {
85 c["lan_ifname"] = "eth0"
86 c["wan_ifname"] = "eth1"
87 c["vlan0ports"] = "0 1 2 3 4 5u"
90 if (model == "Dell TrueMobile 2300 v2") {
91 c["vlan0ports"] = "0 1 2 3 5*"
92 c["vlan1ports"] = "4 5"
94 if (nvram["boardtype"] == "bcm94710r4") {
96 c["lan_ifname"] = "eth0"
97 c["wan_ifname"] = "eth1"
99 if (nvram["boardtype"] == "wgt634u") {
100 c["vlan0ports"] = "0 1 2 3 5*"
101 c["vlan1ports"] = "4 5"
103 if (nvram["boardtype"] == "0x0467") {
104 c["vlan0ports"] = "0 1 2 3 5*"
105 c["vlan1ports"] = "4 5"
107 if ((nvram["boardtype"] == "0x042f") || (nvram["boardtype"] == "0x0472")) {
108 if (nvram["boardnum"] == "45") {
110 c["vlan0ports"] = "1 2 3 4 5*"
111 c["vlan1ports"] = "0 5"
114 c["vlan0ports"] = "0 1 2 3 4 5u"
116 c["lan_ifname"] = "eth0"
117 c["wan_ifname"] = "eth1"
119 # MAC addresses on 4704 tend to be screwed up. Add a workaround here
120 if (nvram["et0macaddr"] ~ mac_check) {
121 c["lan_macaddr"] = nvram["et0macaddr"]
122 c["wan_macaddr"] = macinc(c["lan_macaddr"])
126 # Buffalo WBR-B11 and Buffalo WBR-G54
127 if (nvram["boardtype"] == "bcm94710ap") {
128 c["vlan0ports"] = "0 1 2 3 4 5u"
130 c["lan_ifname"] = "eth0"
131 c["wan_ifname"] = "eth1"
133 if (nvram["boardtype"] == "0x478") {
134 # generic broadcom 4785 processor with 5397 switch?
135 c["vlan0ports"] = "1 2 3 4 8*"
136 c["vlan1ports"] = "0 8"
140 if ((nvram["boardnum"] == "2") || \
141 (nvram["boardnum"] == "1024")) {
142 c["lan_ifname"]="eth0"
147 if ((nvram["boardum"] == "2") && \
148 (nvram["GemtekPmonVer"] == "1")) {
149 c["lan_ifname"]="eth0"
154 # These are actually same as defaults above. For some reason this script applies
155 # Generic BCM94704 settings instead so we revert to proper settings here.
156 # Hopefully someone will fix this properly soon.
157 if (model == "ASUS WL-700gE") {
158 c["lan_ifname"]="eth0.0"
159 c["wan_ifname"]="eth0.1"
160 c["vlan0ports"]="1 2 3 4 5*"
161 c["vlan1ports"]="0 5"
164 if (model == "Motorola WR850G V2/V3") {
165 c["vlan0ports"]="0 1 2 3 5*"
166 c["vlan1ports"]="4 5"
168 if (model == "ASUS WL-500W") {
169 c["lan_ifname"] = "eth0"
170 c["wan_ifname"] = "eth1"
171 c["vlan0ports"] = "0 1 2 3 4 5u"
175 if (c["vlan0ports"] || c["vlan1ports"]) {
176 print "#### VLAN configuration "
177 print "config switch eth0"
178 print " option enable 1"
180 vlan(0, "vlan0ports")
181 vlan(1, "vlan1ports")
183 print "#### Loopback configuration"
184 print "config interface loopback"
185 print " option ifname \"lo\""
186 print " option proto static"
187 print " option ipaddr 127.0.0.1"
188 print " option netmask 255.0.0.0"
191 print "#### LAN configuration"
192 print "config interface lan"
193 print " option type bridge"
194 p("ifname", "lan_ifname")
195 p("macaddr", "lan_macaddr")
196 print " option proto static"
197 print " option ipaddr 192.168.1.1"
198 print " option netmask 255.255.255.0"
201 if (c["wan_ifname"]) {
202 print "#### WAN configuration"
203 print "config interface wan"
204 p("ifname", "wan_ifname")
205 p("macaddr", "wan_macaddr")
206 print " option proto dhcp"
208 print "#### WAN configuration (disabled)"
209 print "#config interface wan"
210 print "# option proto dhcp"
212 }' > /etc
/config
/network
This page took 0.053972 seconds and 5 git commands to generate.