57e6ba1a341c5df07cd4358764cfd78a7e5eaec3
[openwrt/svn-archive/archive.git] / openwrt / target / linux / package / base-files / files / brcm-2.6 / etc / init.d / S05netconfig
1 #!/bin/sh
2 [ -e /etc/config/network ] && exit 0
3
4 (
5 if [ "$(/usr/bin/head -c4 /dev/mtdblock/1 | /usr/bin/tail -c3)" = "ELF" ]; then
6 # WGT634u
7 echo boardtype=wgt634u
8 else
9 strings /dev/mtdblock/3
10 fi
11 ) | awk '
12 function p(name) {
13 if (c[name] != "") print name "=\"" c[name] "\""
14 }
15
16 BEGIN {
17 FS="="
18 c["lan_ifname"]="br0"
19 c["lan_ifnames"]="vlan0 eth1"
20 c["wan_proto"]="none"
21 c["wan_ifname"]="vlan1"
22 c["vlan0ports"]="1 2 3 4 5*"
23 c["vlan1ports"]="0 5"
24 }
25
26 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
27 nvram[$1] = $2
28 }
29
30 END {
31 # v1 hardware
32 if (nvram["boardtype"] == "bcm4710dev") {
33 # Linksys WRT54G v1.x
34 if (nvram["boardnum"] == "42") {
35 c["vlan0ports"]=""
36 c["vlan1ports"]=""
37 c["lan_ifnames"]="vlan2 eth2"
38 }
39
40 # Asus WL-500g
41 if (nvram["boardnum"] == "asusX") {
42 c["lan_ifnames"]="eth0 eth1 eth2" # FIXME
43 # wan_ifname=eth1
44 }
45 }
46 if (nvram["boardtype"] == "wgt634u") {
47 c["vlan0ports"] = "0 1 2 3 5*"
48 c["vlan1ports"] = "4 5"
49 }
50 if (nvram["boardtype"] == "0x0467") {
51 c["vlan0ports"] = "0 1 2 3 5*"
52 c["vlan1ports"] = "4 5"
53 }
54
55 # WAP54G
56 if ((nvram["boardnum"] == "2") || \
57 (nvram["boardnum"] == "1024")) {
58 c["lan_ifnames"]="eth0 eth1"
59 c["wan_ifname"]=""
60 }
61
62 print "#### VLAN configuration "
63 print "vlan0hwname=et0"
64 print "vlan1hwname=et0"
65 p("vlan0ports")
66 p("vlan1ports")
67 print ""
68 print ""
69
70 print "#### LAN configuration"
71 print "lan_proto=\"static\""
72 p("lan_ifname")
73 p("lan_ifnames")
74 print "lan_ipaddr=\"192.168.1.1\""
75 print "# lan_dns=\"192.168.1.1\""
76 print "# lan_gateway=\"192.168.1.1\""
77
78 print ""
79 print ""
80
81 print "#### WAN configuration"
82 print "# wan_proto: WAN protocol, available protocols:"
83 print "# none: disable"
84 print "# dhcp: DHCP"
85 print "# static: Static IP"
86 print "# pppoe: PPP over Ethernet"
87 print "# pptp: Point-to-Point tunneling Protocol"
88 print "# for pppoe and pptp you need to use wan_ifname=\"ppp0\""
89 print "# and {pppoe,pptp}ifname=\"" c["wan_ifname"] "\")"
90 print ""
91 print "wan_proto=dhcp"
92 p("wan_ifname")
93 print "# wan_ipaddr=\"192.168.0.2\""
94 print "# wan_netmask=\"255.255.255.0\""
95 print "# wan_gateway=\"192.168.0.1\""
96 print "# wan_dns=\"192.168.0.1\""
97 print ""
98 print "## PPP over Ethernet and PPTP"
99 print "# wan_ifname=\"ppp0\""
100 print "# pppoe_ifname=\"" c["wan_ifname"] "\""
101 print "# pptp_ifname=\"" c["wan_ifname"] "\""
102 print "# pptp_server_ip=\"192.168.0.1\""
103 }
104 ' > /etc/config/network