rewrite of the network scripts and configuration
[openwrt.git] / package / base-files / brcm-2.6 / etc / init.d / S05netconfig
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 [ -e /etc/config/network ] && exit 0
5
6 mkdir -p /etc/config
7
8 (
9 if grep 'mtd0: 00060000' /proc/mtd 2>&- >&-; then
10 # WGT634u
11 echo boardtype=wgt634u
12 else
13 strings /dev/mtdblock/3
14 fi
15 ) | awk '
16 function p(cfgname, name) {
17 if (c[name] != "") print " option " cfgname " \"" c[name] "\""
18 }
19
20 BEGIN {
21 FS="="
22 c["lan_ifname"]="br0"
23 c["lan_ifnames"]="eth0.0 wl0"
24 c["wan_proto"]="none"
25 c["wan_ifname"]="eth0.1"
26 c["vlan0ports"]="1 2 3 4 5*"
27 c["vlan1ports"]="0 5"
28 }
29
30 ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
31 nvram[$1] = $2
32 }
33
34 END {
35 # v1 hardware
36 if (nvram["boardtype"] == "bcm94710dev") {
37 # Asus WL-500g
38 if (nvram["boardnum"] == "asusX") {
39 c["lan_ifnames"]="eth0 eth1 wl0" # FIXME
40 c["wan_ifname"]=""
41 }
42 }
43 if (nvram["boardtype"] == "wgt634u") {
44 c["vlan0ports"] = "0 1 2 3 5*"
45 c["vlan1ports"] = "4 5"
46 c["lan_ifnames"] = "eth0.0 ath0"
47 }
48 if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
49 c["vlan0ports"] = "0 1 2 3 5*"
50 c["vlan1ports"] = "4 5"
51 }
52
53 # WAP54G
54 if ((nvram["boardnum"] == "2") || \
55 (nvram["boardnum"] == "1024")) {
56 c["lan_ifnames"]="eth0 wl0"
57 c["wan_ifname"]=""
58 }
59
60 print "#### VLAN configuration "
61 print "config switch eth0"
62 p("vlan0", "vlan0ports")
63 p("vlan1", "vlan1ports")
64 print ""
65 print ""
66 print "#### LAN configuration"
67 print "config interface lan"
68 print " option type bridge"
69 p("ifnames", "lan_ifnames")
70 print " option proto static"
71 print " option ipaddr 192.168.1.1"
72 print " option netmask 255.255.255.0"
73 print ""
74 print ""
75 print "#### WAN configuration"
76 print "config interface wan"
77 p("ifname", "wan_ifname")
78 print " option proto dhcp"
79 }
80 ' > /etc/config/network
This page took 0.051897 seconds and 5 git commands to generate.