:
#
# Initalize the address of the Kinetics
# EtherPort Ethernet interface
# We use this script for compatibility with Apple's Documentation.
# modified from ae6 stuff by Holly Knight @ Apple Computers Inc.
#
PATH=/bin:/usr/bin:/etc:/usr/etc
ScriptName=$0

host=`/bin/hostname`

while [ $# != 0 ]; do
    case $1 in
    -C) (
	maxdev=$2	# max number of devices (boards)
        echo " $maxdev Ethernet card(s) installed"
	unit=0
        if [ ! -f /etc/NETADDRS ]; then
	  # get pertinent information and set up data base for first time
	  while [ "$unit" -lt "$maxdev" ]; do
	    while [ "$inetaddr" = "" ]; do
              echo "ep$unit: Please enter an Internet address: \c"
              read inetaddr
	    done
	    while [ "$broadcast" = "" ]; do
              echo "ep$unit: Please enter an Internet Broadcast address: \c"
              read broadcast
	    done
            echo "ep$unit: Please enter a netmask [none]: \c"
            read netmask
	    if [ "$netmask" = "none" ]; then
	      netmask=
	    fi
	    echo "$unit	$inetaddr $broadcast $netmask" >> /etc/NETADDRS
      	echo "$inetaddr $host # `/bin/date`" >> /etc/hosts
		echo "Warning: At boot time, this system's Internet address, Broadcast"
		echo "address and netmask is extracted from the file /etc/NETADDRS."
		echo "Your /etc/hosts file may need editing."

	    unit=`expr $unit + 1`
	    inetaddr=; broadcast=;
	  done
	fi

	# go through /etc/NETADDRS data base, filling in info for new cards
	# allow for possibility (though undesirable) of line containing only
	# unit number
	unit=0
	while [ "$unit" -lt "$maxdev" ]; do
	  set ''`/bin/sed -n "/^[ 	]*$unit/p" /etc/NETADDRS`
	  n=$#
	  inetaddr=$2; broadcast=$3; netmask=$4
	  while [ "$inetaddr" = "" ]; do
            echo "ep$unit: Please enter an Internet address: \c"
            read inetaddr
	  done
	  while [ "$broadcast" = "" ]; do
            echo "ep$unit: Please enter an Internet Broadcast address: \c"
            read broadcast
	  done
	  if [ "$n" -lt 2 ]; then
	    # first time for this card; ask for netmask
            echo "ep$unit: Please enter a netmask [none]: \c"
            read netmask
	    if [ "$netmask" = "none" ]; then
	      netmask=
	    fi
	    echo "$unit	$inetaddr $broadcast $netmask" >> /etc/NETADDRS
      	    echo "$inetaddr $host # `/bin/date`" >> /etc/hosts
	  fi
	  
          echo "ep$unit: hostname is $host with IP address of $inetaddr \c"
	  echo "broadcasting with $broadcast"
	  if [ -n "$netmask" ]; then
		/etc/ifconfig ep$unit "$inetaddr" broadcast "$broadcast" netmask  "$netmask" -trailers
	  else
		/etc/ifconfig ep$unit "$inetaddr" broadcast "$broadcast" -trailers
	  fi
echo    	  /etc/ifconfig  ep$unit

	  unit=`expr $unit + 1`
	done

        )
	;;

    -D)	;;
    -S)	;;
     *)	echo "$ScriptName:  unexpected argument:  $1"
  	exit 1
    	;;
    esac
    shift 2
done
