aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorRod Whitby <rod@whitby.id.au>2006-12-20 13:17:21 +0000
committerRod Whitby <rod@whitby.id.au>2006-12-20 13:17:21 +0000
commita4cca109c1fd39a2b17fd12190e4fa542a9181c4 (patch)
tree4c88a6156b0c03a864452847ea662fe4bb7b1b5b /target
parent246cc4f285265a38beb5f53caaa94d9a2b0b6bb2 (diff)
downloadupstream-a4cca109c1fd39a2b17fd12190e4fa542a9181c4.tar.gz
upstream-a4cca109c1fd39a2b17fd12190e4fa542a9181c4.tar.bz2
upstream-a4cca109c1fd39a2b17fd12190e4fa542a9181c4.zip
Initial stab at netconfig for nslu2 and nas100d
SVN-Revision: 5883
Diffstat (limited to 'target')
-rw-r--r--target/linux/ixp4xx-2.6/base-files.mk5
-rwxr-xr-xtarget/linux/ixp4xx-2.6/base-files/etc/init.d/netconfig94
2 files changed, 99 insertions, 0 deletions
diff --git a/target/linux/ixp4xx-2.6/base-files.mk b/target/linux/ixp4xx-2.6/base-files.mk
new file mode 100644
index 0000000000..d6682bd388
--- /dev/null
+++ b/target/linux/ixp4xx-2.6/base-files.mk
@@ -0,0 +1,5 @@
+define Package/base-files/install-target
+ rm -f $(1)/etc/config/network
+endef
+
+
diff --git a/target/linux/ixp4xx-2.6/base-files/etc/init.d/netconfig b/target/linux/ixp4xx-2.6/base-files/etc/init.d/netconfig
new file mode 100755
index 0000000000..352a2a9a2b
--- /dev/null
+++ b/target/linux/ixp4xx-2.6/base-files/etc/init.d/netconfig
@@ -0,0 +1,94 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=05
+
+# hardware
+# the 'Hardware' string from cpuinfo
+hardware(){
+ sed -n 's!^Hardware *: !!p' /proc/cpuinfo
+}
+#
+# machine
+# outputs an identifier of the current machine - i.e. the board
+# slugos is running on.
+machine(){
+ case "$(hardware)" in
+ *Avila*) echo avila;;
+ *Loft*) echo loft;;
+ *NAS?100d*) echo nas100d;;
+ *DSM?G600*) echo dsmg600;;
+ *NSLU2*) echo nslu2;;
+ *FSG?3*) echo fsg3;;
+ *Gateway?7001*) echo gateway7001;;
+ *) echo unknown;;
+ esac
+}
+
+# Returns the mtd device with the specified name (without leading /dev)
+# $1 = name of mtd device
+get_mtd() {
+ grep "\"$1\"*$" /proc/mtd | cut -d : -f 1
+}
+
+# Returns the mtd block device with the specified name (without leading /dev)
+# $1 = name of mtd device
+get_mtdblock() {
+ echo $(get_mtd "$1") | sed 's/mtd/mtdblock/'
+}
+
+start() {
+ [ -e /etc/config/network ] && exit 0
+
+ mkdir -p /etc/config
+
+ (
+ case "$(machine)" in
+ nslu2)
+ sysconf=$(find_mtd_part "SysConf")
+ echo model=nslu2
+ strings $sysconf ;;
+ nas100d)
+ sysconf=$(find_mtd_part "sysconfig")
+ echo model=nas100d
+ strings $sysconf ;;
+ *)
+ echo model=$(machine) ;;
+ esac
+ ) | awk '
+ function p(cfgname, name) {
+ if (c[name] != "") print " option " cfgname " \"" c[name] "\""
+ }
+
+ BEGIN {
+ FS="="
+ getline model
+ }
+
+ { c[$1] = $2 }
+
+ END {
+ print "#### Loopback configuration"
+ print "config interface loopback"
+ print " option ifname \"lo\""
+ print " option proto static"
+ print " option ipaddr 127.0.0.1"
+ print " option netmask 255.0.0.0"
+ print ""
+ print ""
+ print "#### LAN configuration"
+ print "config interface lan"
+ print " option ifname eth0"
+ if ((model == "nslu2") || (model == "nas100d")) {
+ p("proto", "bootproto")
+ p("ipaddr", "ip_addr")
+ p("netmask", "netmask")
+ p("gateway", "gateway")
+ p("dns", "dns_server1")
+ p("hostname", "disk_server_name")
+ }
+ else {
+ print " option proto dhcp"
+ }
+ }' > /etc/config/network
+}