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 macinc(mac, maca, i, result) {
25 for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i]
26 if (++maca[6] > 0xff) {
30 for (i = 1; i <= 6; i++) {
31 if (i != 1) result = result ":"
32 result = result sprintf("%02x", maca[i])
39 c["lan_ifname"]="eth0.0"
40 c["wan_ifname"]="eth0.1"
41 c["vlan0ports"]="1 2 3 4 5*"
43 getline < "/proc/diag/model"
45 for (i = 0; i < 6; i++) {
46 if (mac_check != "") mac_check = mac_check ":"
47 mac_check = mac_check "[0-9a-fA-F][0-9a-fA-F]"
51 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") || ($1 ~ /macaddr/) {
56 if ((model == "ASUS WL-HDD") || (model == "ASUS WL-300g") || (model == "Linksys WAP54G V1")) {
58 c["lan_ifname"] = "eth1"
60 if (model == "ASUS WL-330gE") {
62 c["lan_ifname"] = "eth0"
66 if (model == "ASUS WL-500g") {
67 c["wan_ifname"] = "eth1"
68 c["lan_ifname"] = "eth0"
70 if (model == "ASUS WL-500g Premium V2") {
71 c["vlan0ports"] = "0 1 2 3 5*"
72 c["vlan1ports"] = "4 5"
74 if (model == "Dell TrueMobile 2300") {
75 c["lan_ifname"] = "eth0"
76 c["wan_ifname"] = "eth1"
77 c["vlan0ports"] = "0 1 2 3 4 5u"
80 if (model == "Dell TrueMobile 2300 v2") {
81 c["vlan0ports"] = "0 1 2 3 5*"
82 c["vlan1ports"] = "4 5"
84 if (nvram["boardtype"] == "bcm94710r4") {
86 c["lan_ifname"] = "eth0"
87 c["wan_ifname"] = "eth1"
89 if (nvram["boardtype"] == "wgt634u") {
90 c["vlan0ports"] = "0 1 2 3 5*"
91 c["vlan1ports"] = "4 5"
93 if (nvram["boardtype"] == "0x0467") {
94 c["vlan0ports"] = "0 1 2 3 5*"
95 c["vlan1ports"] = "4 5"
97 if ((nvram["boardtype"] == "0x042f") || (nvram["boardtype"] == "0x0472")) {
98 if (nvram["boardnum"] == "45") {
100 c["vlan0ports"] = "1 2 3 4 5*"
101 c["vlan1ports"] = "0 5"
104 c["vlan0ports"] = "0 1 2 3 4 5u"
106 c["lan_ifname"] = "eth0"
107 c["wan_ifname"] = "eth1"
109 # MAC addresses on 4704 tend to be screwed up. Add a workaround here
110 if (nvram["et0macaddr"] ~ mac_check) {
111 c["lan_macaddr"] = nvram["et0macaddr"]
112 c["wan_macaddr"] = macinc(c["lan_macaddr"])
116 if (nvram["boardtype"] == "0x478") {
117 # generic broadcom 4785 processor with 5397 switch?
118 c["vlan0ports"] = "1 2 3 4 8*"
119 c["vlan1ports"] = "0 8"
123 if ((nvram["boardnum"] == "2") || \
124 (nvram["boardnum"] == "1024")) {
125 c["lan_ifname"]="eth0"
130 if ((nvram["boardum"] == "2") && \
131 (nvram["GemtekPmonVer"] == "1")) {
132 c["lan_ifname"]="eth0"
137 # These are actually same as defaults above. For some reason this script applies
138 # Generic BCM94704 settings instead so we revert to proper settings here.
139 # Hopefully someone will fix this properly soon.
140 if (model == "ASUS WL-700gE") {
141 c["lan_ifname"]="eth0.0"
142 c["wan_ifname"]="eth0.1"
143 c["vlan0ports"]="1 2 3 4 5*"
144 c["vlan1ports"]="0 5"
147 if (model == "Motorola WR850G V2/V3") {
148 c["vlan0ports"]="0 1 2 3 5*"
149 c["vlan1ports"]="4 5"
151 if (model == "ASUS WL-500W") {
152 c["lan_ifname"] = "eth0"
153 c["wan_ifname"] = "eth1"
154 c["vlan0ports"] = "0 1 2 3 4 5u"
158 if (c["vlan0ports"] || c["vlan1ports"]) {
159 print "#### VLAN configuration "
160 print "config switch eth0"
161 p("vlan0", "vlan0ports")
162 p("vlan1", "vlan1ports")
166 print "#### Loopback configuration"
167 print "config interface loopback"
168 print " option ifname \"lo\""
169 print " option proto static"
170 print " option ipaddr 127.0.0.1"
171 print " option netmask 255.0.0.0"
174 print "#### LAN configuration"
175 print "config interface lan"
176 print " option type bridge"
177 p("ifname", "lan_ifname")
178 p("macaddr", "lan_macaddr")
179 print " option proto static"
180 print " option ipaddr 192.168.1.1"
181 print " option netmask 255.255.255.0"
184 if (c["wan_ifname"]) {
185 print "#### WAN configuration"
186 print "config interface wan"
187 p("ifname", "wan_ifname")
188 p("macaddr", "wan_macaddr")
189 print " option proto dhcp"
191 print "#### WAN configuration (disabled)"
192 print "#config interface wan"
193 print "# option proto dhcp"
195 }' > /etc
/config
/network
This page took 0.063121 seconds and 5 git commands to generate.