add netconfig fix for wl-500g premium
[openwrt.git] / package / base-files / brcm-2.6 / 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 /dev/mtdblock/3
17 fi
18 ) | awk '
19 function p(cfgname, name) {
20 if (c[name] != "") print " option " cfgname " \"" c[name] "\""
21 }
22
23 BEGIN {
24 FS="="
25 c["lan_ifname"]="eth0.0"
26 c["wan_ifname"]="eth0.1"
27 c["vlan0ports"]="1 2 3 4 5*"
28 c["vlan1ports"]="0 5"
29 }
30
31 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
32 nvram[$1] = $2
33 }
34
35 END {
36 # v1 hardware
37 if (nvram["boardtype"] == "bcm94710dev") {
38 # Asus WL-500g
39 if (nvram["boardnum"] == "asusX") {
40 c["lan_ifname"]="eth0 eth1" # FIXME
41 c["wan_ifname"]=""
42 }
43 }
44 if (nvram["boardtype"] == "bcm94710r4") {
45 # Toshiba WRC-1000
46 c["lan_ifname"] = "eth0"
47 c["wan_ifname"] = "eth1"
48 }
49 if (nvram["boardtype"] == "wgt634u") {
50 c["vlan0ports"] = "0 1 2 3 5*"
51 c["vlan1ports"] = "4 5"
52 }
53 if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
54 if (nvram["boardnum"] == "45") {
55 c["vlan0ports"] = "1 2 3 4 5*"
56 c["vlan1ports"] = "0 5"
57 } else {
58 c["vlan0ports"] = "0 1 2 3 5*"
59 c["vlan1ports"] = "4 5"
60 }
61 }
62
63 # WAP54G
64 if ((nvram["boardnum"] == "2") || \
65 (nvram["boardnum"] == "1024")) {
66 c["lan_ifname"]="eth0"
67 c["wan_ifname"]=""
68 }
69
70 print "#### VLAN configuration "
71 print "config switch eth0"
72 p("vlan0", "vlan0ports")
73 p("vlan1", "vlan1ports")
74 print ""
75 print ""
76 print "#### Loopback configuration"
77 print "config interface loopback"
78 print " option ifname \"lo\""
79 print " option proto static"
80 print " option ipaddr 127.0.0.1"
81 print " option netmask 255.0.0.0"
82 print ""
83 print ""
84 print "#### LAN configuration"
85 print "config interface lan"
86 print " option type bridge"
87 p("ifname", "lan_ifname")
88 print " option proto static"
89 print " option ipaddr 192.168.1.1"
90 print " option netmask 255.255.255.0"
91 print ""
92 print ""
93 print "#### WAN configuration"
94 print "config interface wan"
95 p("ifname", "wan_ifname")
96 print " option proto dhcp"
97 }' > /etc/config/network
98 }
This page took 0.055717 seconds and 5 git commands to generate.