#!/bin/bash
# $Header$

# IFACE      = Logical interface name
# MODE       = start | stop
# METHOD     = manual, otherwise exit!
# IF_ADDRESS = address/prefix
# IF_DEVICE  = physical interface name
# IF_SCOPE   = scope of address
# IF_BRD     = broadcast address (all1 default, all0/none allowed)
# IF_FLAGS   = "secondary"

. /etc/network/ifupdown-scripts-zg2.d/common-functions

case "$MODE" in
  start)
    cmd "ip link set dev \"$IF_DEVICE\" up"
    ;;
  stop)
    DEV=$(state_entry dev)
    if [ -n "$DEV" ]; then
      if has_ip_address "$DEV"; then
        # device doesn't have any more IP addresses
        if ! is_active_vlan_master "$DEV"; then
          # if we take down an interface that is an active vlan master,
	  # we take down all VLANs. Not a good idea.
          cmd "ip link set dev $DEV down"
	fi
      fi
    fi
    ;;
  *)
    ;;
esac

# end of file
