rewrite of the network scripts and configuration
[openwrt-10.03/.git] / package / switch / files / switch.sh
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 setup_switch_vlan() {
5         DIR="/proc/switch/$CONFIG_SECTION/vlan/$1"
6         [ -d "$DIR" ] || return 0
7         
8         config_get ports "$CONFIG_SECTION" "vlan$1"
9         echo "$ports" > "$DIR/ports"
10 }
11
12 setup_switch() {
13         config_cb() {
14                 case "$1" in
15                         switch)
16                                 [ -n "$2" -a -d "/proc/switch/$2" ] && {
17                                         echo 1 > "/proc/switch/$2/reset"
18                                         echo 1 > "/proc/switch/$2/enable"
19                                         echo 1 > "/proc/switch/$2/enable_vlan"
20                                         option_cb() {
21                                                 case "$1" in
22                                                         vlan*) setup_switch_vlan "${1##vlan}";;
23                                                 esac
24                                         }
25                                 }
26                         ;;
27                         *)
28                                 option_cb() { return 0; }
29                         ;;
30                 esac
31         }
32         config_load network
33 }