c8743539d82f5839be180df9d4a1709ad41f0053
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-500g") {
61 c["wan_ifname"] = "eth1"
62 c["lan_ifname"] = "eth0"
64 if (model == "ASUS WL-500g Premium V2") {
65 c["vlan0ports"] = "0 1 2 3 5*"
66 c["vlan1ports"] = "4 5"
69 if (model == "Dell TrueMobile 2300") {
70 c["vlan0ports"] = "0 1 2 3 5*"
71 c["vlan1ports"] = "4 5"
73 if (nvram["boardtype"] == "bcm94710r4") {
75 c["lan_ifname"] = "eth0"
76 c["wan_ifname"] = "eth1"
78 if (nvram["boardtype"] == "wgt634u") {
79 c["vlan0ports"] = "0 1 2 3 5*"
80 c["vlan1ports"] = "4 5"
82 if (nvram["boardtype"] == "0x0467") {
83 c["vlan0ports"] = "0 1 2 3 5*"
84 c["vlan1ports"] = "4 5"
86 if ((nvram["boardtype"] == "0x042f") || (nvram["boardtype"] == "0x0472")) {
87 if (nvram["boardnum"] == "45") {
89 c["vlan0ports"] = "1 2 3 4 5*"
90 c["vlan1ports"] = "0 5"
93 c["vlan0ports"] = "0 1 2 3 4 5u"
95 c["lan_ifname"] = "eth0"
96 c["wan_ifname"] = "eth1"
98 # MAC addresses on 4704 tend to be screwed up. Add a workaround here
99 if (nvram["et0macaddr"] ~ mac_check) {
100 c["lan_macaddr"] = nvram["et0macaddr"]
101 c["wan_macaddr"] = macinc(c["lan_macaddr"])
107 if ((nvram["boardnum"] == "2") || \
108 (nvram["boardnum"] == "1024")) {
109 c["lan_ifname"]="eth0"
114 if ((nvram["boardum"] == "2") && \
115 (nvram["GemtekPmonVer"] == "1")) {
116 c["lan_ifname"]="eth0"
121 # These are actually same as defaults above. For some reason this script applies
122 # Generic BCM94704 settings instead so we revert to proper settings here.
123 # Hopefully someone will fix this properly soon.
124 if (model == "ASUS WL-700gE") {
125 c["lan_ifname"]="eth0.0"
126 c["wan_ifname"]="eth0.1"
127 c["vlan0ports"]="1 2 3 4 5*"
128 c["vlan1ports"]="0 5"
131 if (model == "Motorola WR850G V2/V3") {
132 c["vlan0ports"]="0 1 2 3 5*"
133 c["vlan1ports"]="4 5"
136 print "#### VLAN configuration "
137 print "config switch eth0"
138 p("vlan0", "vlan0ports")
139 p("vlan1", "vlan1ports")
142 print "#### Loopback configuration"
143 print "config interface loopback"
144 print " option ifname \"lo\""
145 print " option proto static"
146 print " option ipaddr 127.0.0.1"
147 print " option netmask 255.0.0.0"
150 print "#### LAN configuration"
151 print "config interface lan"
152 print " option type bridge"
153 p("ifname", "lan_ifname")
154 p("macaddr", "lan_macaddr")
155 print " option proto static"
156 print " option ipaddr 192.168.1.1"
157 print " option netmask 255.255.255.0"
160 print "#### WAN configuration"
161 print "config interface wan"
162 p("ifname", "wan_ifname")
163 p("macaddr", "wan_macaddr")
164 print " option proto dhcp"
165 }' > /etc
/config
/network
This page took 0.048132 seconds and 3 git commands to generate.