#!/bin/sh

if [ -n "$DEBUG" ]; then
  echo "$0: Beginning $1"
fi

case "$1" in
  up)
    if [ -z "${DHCP_DEV}" -o -z "${DHCP_IPADDR}" ]; then
      echo "$0: DHCP_DEV or DHCP_IPADDR not set!" 1>&2
      exit 1
    fi

    ifconfig_opts=""
		
    if [ -n "${DHCP_SUBNET_MASK}" ]; then
      ifconfig_opts="$ifconfig_opts netmask ${DHCP_SUBNET_MASK}"
    fi

    /sbin/ifconfig "${DHCP_DEV}" "${DHCP_IPADDR}" $ifconfig_opts up

    ;;

  down)
    /sbin/ifconfig "${DHCP_DEV}" down
    ;;

  *)
    echo "Usage: $0 up|down" 1>&2
    exit 1
    ;;
esac

if [ -n "$DEBUG" ]; then
  echo "$0: Ending $1"
fi

exit 0
