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