mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-23 23:46:16 +02:00
add config file support for the adm5120 switch
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@10529 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
dabfb71139
commit
42c72797dc
@ -43,6 +43,10 @@ endef
|
|||||||
define Package/admswconfig/install
|
define Package/admswconfig/install
|
||||||
$(INSTALL_DIR) $(1)/sbin
|
$(INSTALL_DIR) $(1)/sbin
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/admswconfig $(1)/sbin/
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/admswconfig $(1)/sbin/
|
||||||
|
$(INSTALL_DIR) $(1)/lib/network/
|
||||||
|
$(INSTALL_DATA) ./files/admswswitch.sh $(1)/lib/network/admswswitch.sh
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/admswconfig $(1)/etc/init.d/admswconfig
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,admswconfig))
|
$(eval $(call BuildPackage,admswconfig))
|
||||||
|
67
package/admswconfig/files/admswconfig
Normal file
67
package/admswconfig/files/admswconfig
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2006 OpenWrt.org
|
||||||
|
|
||||||
|
START=05
|
||||||
|
|
||||||
|
start() {
|
||||||
|
[ -e /etc/config/network ] && exit 0
|
||||||
|
|
||||||
|
mkdir -p /etc/config
|
||||||
|
|
||||||
|
adm5120_detect() {
|
||||||
|
board_name=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /system type/ {print $2}' /proc/cpuinfo)
|
||||||
|
|
||||||
|
case "$board_name" in
|
||||||
|
"Compex WP54"*)
|
||||||
|
board="WP54";;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
adm5120_detect
|
||||||
|
BEGIN {
|
||||||
|
FS="="
|
||||||
|
c["lan_ifname"]="eth0"
|
||||||
|
c["wan_ifname"]="eth1"
|
||||||
|
c["eth0ports"]="12345"
|
||||||
|
c["eth1ports"]="0"
|
||||||
|
}
|
||||||
|
|
||||||
|
END {
|
||||||
|
if (model == "Compex WP54") {
|
||||||
|
c["vlan0ports"]="0"
|
||||||
|
c["vlan1ports"]="1"
|
||||||
|
}
|
||||||
|
|
||||||
|
print "#### VLAN configuration "
|
||||||
|
print "config switch"
|
||||||
|
p("eth0", "eth0ports")
|
||||||
|
p("eth1", "eth1ports")
|
||||||
|
print ""
|
||||||
|
print ""
|
||||||
|
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 type bridge"
|
||||||
|
p("ifname", "lan_ifname")
|
||||||
|
p("macaddr", "lan_macaddr")
|
||||||
|
print " option proto static"
|
||||||
|
print " option ipaddr 192.168.1.1"
|
||||||
|
print " option netmask 255.255.255.0"
|
||||||
|
print ""
|
||||||
|
print ""
|
||||||
|
print "#### WAN configuration"
|
||||||
|
print "config interface wan"
|
||||||
|
p("ifname", "wan_ifname")
|
||||||
|
p("macaddr", "wan_macaddr")
|
||||||
|
print " option proto dhcp"
|
||||||
|
}' > /etc/config/network
|
||||||
|
}
|
25
package/admswconfig/files/admswswitch.sh
Normal file
25
package/admswconfig/files/admswswitch.sh
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Copyright (C) 2006 OpenWrt.org
|
||||||
|
|
||||||
|
setup_switch_vlan() {
|
||||||
|
config_get ports "$CONFIG_SECTION" "eth$1"
|
||||||
|
admswconfig eth$1 ${ports}c
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_switch() {
|
||||||
|
config_cb() {
|
||||||
|
case "$1" in
|
||||||
|
switch)
|
||||||
|
option_cb() {
|
||||||
|
case "$1" in
|
||||||
|
eth*) setup_switch_vlan "${1##eth}";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
option_cb() { return 0; }
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
config_load network
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user