kirkwood: add *plugs to uci-defaults
[openwrt.git] / target / linux / kirkwood / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2012-2014 OpenWrt.org
4 #
5
6 [ -e /etc/config/network ] && exit 0
7
8 touch /etc/config/network
9
10 set_lan_dhcp() {
11         local ifname=$1
12         uci batch <<EOF
13 set network.lan='interface'
14 set network.lan.ifname='$ifname'
15 set network.lan.proto='dhcp'
16 set network.lan6='interface'
17 set network.lan6.ifname='@lan'
18 set network.lan6.proto='dhcpv6'
19 set network.lan6.reqprefix='no'
20 EOF
21 }
22
23 add_port_based_vlan() {
24         local device=$1
25         local vlan=$2
26         local ports=$3
27         uci batch <<EOF
28 add network switch_vlan
29 set network.@switch_vlan[-1].device='$device'
30 set network.@switch_vlan[-1].vlan='$vlan'
31 set network.@switch_vlan[-1].ports='$ports'
32 set network.@switch_vlan[-1].port_based='1'
33 EOF
34 }
35
36 . /lib/functions/uci-defaults.sh
37 . /lib/kirkwood.sh
38
39 board=$(kirkwood_board_name)
40
41 ucidef_set_interface_loopback
42
43 case "$board" in
44 "dockstar")
45         set_lan_dhcp "eth0"
46         ;;
47 "iconnect")
48         set_lan_dhcp "eth0"
49         ;;
50 "ib62x0")
51         set_lan_dhcp "eth0"
52         ;;
53 "pogo_e02")
54         set_lan_dhcp "eth0"
55         ;;
56 "ea3500")
57         ucidef_set_interfaces_lan_wan "eth0" "eth1"
58         ;;
59 "ea4500")
60         ucidef_set_interfaces_lan_wan "eth0" "eth1"
61         ucidef_add_switch "switch0" "1" "0"
62         add_port_based_vlan "switch0" "1" "0 1 2 3 5"
63         add_port_based_vlan "switch0" "2" "4 6"
64         ;;
65 "guruplug-server-plus")
66         set_lan_dhcp "eth0" "eth1"
67         ;;
68 "sheevaplug" | \
69 "sheevaplug-esata")
70         set_lan_dhcp "eth0"
71         ;;
72 *)
73         ucidef_set_interface_lan "eth0"
74         ;;
75 esac
76
77 uci commit network
78
79 exit 0