Moved netconfig (for ixp4xx only) to S15, so that it can access /proc/cpuinfo to...
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx-2.6 / base-files / etc / init.d / netconfig
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3
4 START=15
5
6 # hardware
7 # the 'Hardware' string from cpuinfo
8 hardware(){
9 sed -n 's!^Hardware *: !!p' /proc/cpuinfo
10 }
11 #
12 # machine
13 # outputs an identifier of the current machine - i.e. the board
14 # slugos is running on.
15 machine(){
16 case "$(hardware)" in
17 *Avila*) echo avila;;
18 *Loft*) echo loft;;
19 *NAS?100d*) echo nas100d;;
20 *DSM?G600*) echo dsmg600;;
21 *NSLU2*) echo nslu2;;
22 *FSG?3*) echo fsg3;;
23 *Gateway?7001*) echo gateway7001;;
24 *) echo unknown;;
25 esac
26 }
27
28 start() {
29 [ -e /etc/config/network ] && exit 0
30
31 mkdir -p /etc/config
32
33 (
34 case "$(machine)" in
35 nslu2)
36 sysconf=$(find_mtd_part "SysConf")
37 echo model=nslu2
38 strings $sysconf ;;
39 nas100d)
40 sysconf=$(find_mtd_part "sysconfig")
41 echo model=nas100d
42 strings $sysconf ;;
43 *)
44 echo model=$(machine) ;;
45 esac
46 ) | awk '
47 function p(cfgname, name) {
48 if (c[name] != "") print " option " cfgname " \"" c[name] "\""
49 }
50
51 BEGIN {
52 FS="="
53 }
54
55 { c[$1] = $2 }
56
57 END {
58 print "#### Loopback configuration"
59 print "config interface loopback"
60 print " option ifname \"lo\""
61 print " option proto static"
62 print " option ipaddr 127.0.0.1"
63 print " option netmask 255.0.0.0"
64 print ""
65 print ""
66 print "#### LAN configuration"
67 print "config interface lan"
68 print " option ifname \"eth0\""
69 if ((c["model"] == "nslu2") || (c["model"] == "nas100d")) {
70 p("proto", "bootproto")
71 p("ipaddr", "ip_addr")
72 p("netmask", "netmask")
73 p("gateway", "gateway")
74 p("dns", "dns_server1")
75 p("hostname", "disk_server_name")
76 }
77 else {
78 print " option proto dhcp"
79 }
80 }' > /etc/config/network
81
82 ifup loopback
83 ifup lan
84 }