#!/bin/bash
# $Header$

# MODE       = start | stop
# IF_DEVICE  = physical interface name

. /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
