#!/bin/sh /etc/rc.common

#### by mzc 2008.12.03

START=99
STOP=99

apply_lease() {
	local cfg="$1"

   
    config_get ifname "$cfg" ifname
    
	config_get vlanid  "$cfg" vlanid

    ifconfig $ifname up

    vconfig add $ifname $vlanid
    ifconfig $ifname.$vlanid up
}

delete_lease() {
	
    local vlan_config_path="/proc/net/vlan/config"
    if [ -e "$vlan_config_path" ]; then
        local laniface=`sed  -n  -e  '1,2d;p'  -e  's/[\t  ]\{1,\}/  /g' /proc/net/vlan/config  | awk '{print $1}' 2>/dev/null`

        for n in $laniface; do
            vconfig rem $n
        done
    fi

}

start() {
	
	config_load switch
    delete_lease
	config_foreach apply_lease

	return 0
}

restart() {
    stop
    start
    return 0
}

stop() {

	delete_lease
	return 0
}

