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 /dev
/mtdblock
/3
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 (nvram["boardtype"] == "bcm94710r4") {
66 c["lan_ifname"] = "eth0"
67 c["wan_ifname"] = "eth1"
69 if (nvram["boardtype"] == "wgt634u") {
70 c["vlan0ports"] = "0 1 2 3 5*"
71 c["vlan1ports"] = "4 5"
73 if (nvram["boardtype"] == "0x0467") {
74 c["vlan0ports"] = "0 1 2 3 5*"
75 c["vlan1ports"] = "4 5"
77 if ((nvram["boardtype"] == "0x042f") || (nvram["boardtype"] == "0x0472")) {
78 if (nvram["boardnum"] == "45") {
80 c["vlan0ports"] = "1 2 3 4 5*"
81 c["vlan1ports"] = "0 5"
84 c["vlan0ports"] = "0 1 2 3 4 5u"
86 c["lan_ifname"] = "eth0"
87 c["wan_ifname"] = "eth1"
89 # MAC addresses on 4704 tend to be screwed up. Add a workaround here
90 if (nvram["et0macaddr"] ~ mac_check) {
91 c["lan_macaddr"] = nvram["et0macaddr"]
92 c["wan_macaddr"] = macinc(c["lan_macaddr"])
98 if ((nvram["boardnum"] == "2") || \
99 (nvram["boardnum"] == "1024")) {
100 c["lan_ifname"]="eth0"
105 # These are actually same as defaults above. For some reason this script applies
106 # Generic BCM94704 settings instead so we revert to proper settings here.
107 # Hopefully someone will fix this properly soon.
108 if (model == "ASUS WL-700gE") {
109 c["lan_ifname"]="eth0.0"
110 c["wan_ifname"]="eth0.1"
111 c["vlan0ports"]="1 2 3 4 5*"
112 c["vlan1ports"]="0 5"
115 print "#### VLAN configuration "
116 print "config switch eth0"
117 p("vlan0", "vlan0ports")
118 p("vlan1", "vlan1ports")
121 print "#### Loopback configuration"
122 print "config interface loopback"
123 print " option ifname \"lo\""
124 print " option proto static"
125 print " option ipaddr 127.0.0.1"
126 print " option netmask 255.0.0.0"
129 print "#### LAN configuration"
130 print "config interface lan"
131 print " option type bridge"
132 p("ifname", "lan_ifname")
133 p("macaddr", "lan_macaddr")
134 print " option proto static"
135 print " option ipaddr 192.168.1.1"
136 print " option netmask 255.255.255.0"
139 print "#### WAN configuration"
140 print "config interface wan"
141 p("ifname", "wan_ifname")
142 p("macaddr", "wan_macaddr")
143 print " option proto dhcp"
144 }' > /etc
/config
/network
This page took 0.066361 seconds and 5 git commands to generate.