[kernel] remove no longer used configs and patches
[openwrt.git] / target / linux / brcm-2.4 / base-files / etc / init.d / netconfig
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3
4 START=05
5
6 start() {
7 [ -e /etc/config/network ] && exit 0
8
9 mkdir -p /etc/config
10
11 (
12 if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
13 # WGT634u
14 echo boardtype=wgt634u
15 else
16 strings "$(find_mtd_part nvram)"
17 fi
18 ) | awk '
19 function p(cfgname, name) {
20 if (c[name] != "") print " option " cfgname " \"" c[name] "\""
21 }
22
23 function macinc(mac, maca, i, result) {
24 split(mac, maca, ":")
25 for (i = 1; i <= 6; i++) maca[i] = "0x" maca[i]
26 if (++maca[6] > 0xff) {
27 maca[5]++
28 maca[6] = 0
29 }
30 for (i = 1; i <= 6; i++) {
31 if (i != 1) result = result ":"
32 result = result sprintf("%02x", maca[i])
33 }
34 return result
35 }
36
37 BEGIN {
38 FS="="
39 c["lan_ifname"]="eth0.0"
40 c["wan_ifname"]="eth0.1"
41 c["vlan0ports"]="1 2 3 4 5*"
42 c["vlan1ports"]="0 5"
43 getline < "/proc/diag/model"
44 model=$0
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]"
48 }
49 }
50
51 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") || ($1 ~ /macaddr/) {
52 nvram[$1] = $2
53 }
54
55 END {
56 if ((model == "ASUS WL-HDD") || (model == "ASUS WL-300g") || (model == "Linksys WAP54G V1")) {
57 c["wan_ifname"] = ""
58 c["lan_ifname"] = "eth1"
59 }
60 if (model == "ASUS WL-330gE") {
61 c["wan_ifname"] = ""
62 c["lan_ifname"] = "eth0"
63 c["vlan0ports"] = ""
64 c["vlan1ports"] = ""
65 }
66 if (model == "ASUS WL-500g") {
67 c["wan_ifname"] = "eth1"
68 c["lan_ifname"] = "eth0"
69 }
70 if (model == "ASUS WL-500g Premium V2") {
71 c["vlan0ports"] = "0 1 2 3 5*"
72 c["vlan1ports"] = "4 5"
73 }
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"
78 c["vlan1ports"] = ""
79 }
80 if (model == "Dell TrueMobile 2300 v2") {
81 c["vlan0ports"] = "0 1 2 3 5*"
82 c["vlan1ports"] = "4 5"
83 }
84 if (nvram["boardtype"] == "bcm94710r4") {
85 # Toshiba WRC-1000
86 c["lan_ifname"] = "eth0"
87 c["wan_ifname"] = "eth1"
88 }
89 if (nvram["boardtype"] == "wgt634u") {
90 c["vlan0ports"] = "0 1 2 3 5*"
91 c["vlan1ports"] = "4 5"
92 }
93 if (nvram["boardtype"] == "0x0467") {
94 c["vlan0ports"] = "0 1 2 3 5*"
95 c["vlan1ports"] = "4 5"
96 }
97 if ((nvram["boardtype"] == "0x042f") || (nvram["boardtype"] == "0x0472")) {
98 if (nvram["boardnum"] == "45") {
99 # WL-500gP
100 c["vlan0ports"] = "1 2 3 4 5*"
101 c["vlan1ports"] = "0 5"
102 } else {
103 # Generic BCM94704
104 c["vlan0ports"] = "0 1 2 3 4 5u"
105 c["vlan1ports"] = ""
106 c["lan_ifname"] = "eth0"
107 c["wan_ifname"] = "eth1"
108
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"])
113 }
114 }
115 }
116 # Buffalo WBR-B11 and Buffalo WBR-G54
117 if (nvram["boardtype"] == "bcm94710ap") {
118 c["vlan0ports"] = "0 1 2 3 4 5u"
119 c["vlan1ports"] = ""
120 c["lan_ifname"] = "eth0"
121 c["wan_ifname"] = "eth1"
122 }
123 if (nvram["boardtype"] == "0x478") {
124 # generic broadcom 4785 processor with 5397 switch?
125 c["vlan0ports"] = "1 2 3 4 8*"
126 c["vlan1ports"] = "0 8"
127 }
128
129 # WAP54G
130 if ((nvram["boardnum"] == "2") || \
131 (nvram["boardnum"] == "1024")) {
132 c["lan_ifname"]="eth0"
133 c["wan_ifname"]=""
134 }
135
136 # Sitecom WL-105b
137 if ((nvram["boardum"] == "2") && \
138 (nvram["GemtekPmonVer"] == "1")) {
139 c["lan_ifname"]="eth0"
140 c["wan_ifname"]=""
141 }
142
143 # ASUS WL-700gE
144 # These are actually same as defaults above. For some reason this script applies
145 # Generic BCM94704 settings instead so we revert to proper settings here.
146 # Hopefully someone will fix this properly soon.
147 if (model == "ASUS WL-700gE") {
148 c["lan_ifname"]="eth0.0"
149 c["wan_ifname"]="eth0.1"
150 c["vlan0ports"]="1 2 3 4 5*"
151 c["vlan1ports"]="0 5"
152 }
153
154 if (model == "Motorola WR850G V2/V3") {
155 c["vlan0ports"]="0 1 2 3 5*"
156 c["vlan1ports"]="4 5"
157 }
158 if (model == "ASUS WL-500W") {
159 c["lan_ifname"] = "eth0"
160 c["wan_ifname"] = "eth1"
161 c["vlan0ports"] = "0 1 2 3 4 5u"
162 c["vlan1ports"] = ""
163 }
164
165 if (c["vlan0ports"] || c["vlan1ports"]) {
166 print "#### VLAN configuration "
167 print "config switch eth0"
168 p("vlan0", "vlan0ports")
169 p("vlan1", "vlan1ports")
170 print ""
171 print ""
172 }
173 print "#### Loopback configuration"
174 print "config interface loopback"
175 print " option ifname \"lo\""
176 print " option proto static"
177 print " option ipaddr 127.0.0.1"
178 print " option netmask 255.0.0.0"
179 print ""
180 print ""
181 print "#### LAN configuration"
182 print "config interface lan"
183 print " option type bridge"
184 p("ifname", "lan_ifname")
185 p("macaddr", "lan_macaddr")
186 print " option proto static"
187 print " option ipaddr 192.168.1.1"
188 print " option netmask 255.255.255.0"
189 print ""
190 print ""
191 if (c["wan_ifname"]) {
192 print "#### WAN configuration"
193 print "config interface wan"
194 p("ifname", "wan_ifname")
195 p("macaddr", "wan_macaddr")
196 print " option proto dhcp"
197 } else {
198 print "#### WAN configuration (disabled)"
199 print "#config interface wan"
200 print "# option proto dhcp"
201 }
202 }' > /etc/config/network
203 }
This page took 0.06283 seconds and 5 git commands to generate.