#!/bin/sh

#
# parameters: start, stop, restart
#

INTF=eth0:0

stop_intf()
{
    ifconfig ${INTF} down
}

start_intf()
{
  IP=$(teste -C eth_ip_alias)

  if [ -z "${IP}" ] ; then
    return
  fi

  MASK=$(teste -C eth_mask_alias)
  BROADCAST=$(ipcalc -b ${IP} ${MASK} | cut -d = -f 2)

  ifconfig ${INTF} ${IP} netmask ${MASK} broadcast ${BROADCAST} up

}

case ${1} in
start)
  start_intf
  ;;
stop)
  stop_intf
  ;;
restart)
  stop_intf
  start_intf
  ;;
*)
  echo "${0}: ERROR - invalid option '${1}'"
  ;;
esac

