# install script for the net.  First it should add the hostname to
# /etc hosts.
HOSTS=/usr/etc/inet/hosts
RESOLV=/usr/etc/inet/resolv.conf
NAMED=/usr/etc/inet/named
RC=/usr/etc/inet/rc.net
TMPFILE=/tmp/rc.net$$
RCLOCAL=/etc/rc.local

HOSTNAME=`hostname`

cp $RC.orig $RC

while [ "$IPADDRESS" = "" ]; do
	echo -n "Enter Ip Address for $HOSTNAME (aaa.bbb.ccc.ddd):"
	read IPADDRESS
done

while [ "$NET" = "" ]; do
	echo -n "Enter Net Address for $HOSTNAME (aaa.bbb.ccc.0):"
	read NET
done

while [ "$ROUTER" = "" ]; do
	echo -n "Enter Router Address for $HOSTNAME (aaa.bbb.ccc.ddd):"
	read ROUTER
done

while [ "$DOMAIN" = "" ]; do
	echo -n "Enter Domain Name for $HOSTNAME:"
	read DOMAIN
done

echo "# next two lines added by install.net" >>$HOSTS
echo "$IPADDRESS	$HOSTNAME $HOSTNAME.$DOMAIN" >>$HOSTS
echo "127.0.0.1	loopback" >>$HOSTS
echo "#end of lines added by install.net" >>$HOSTS

echo "$IPADDRESS	$HOSTNAME $HOSTNAME.$DOMAIN"

while [ "$NAMESERVER" = "" ]; do
	echo -n "Name Server for Domain $DOMAIN (aaa.bbb.ccc.ddd):"
	read NAMESERVER
done

echo "You may add more nameservers by editing $RESOLV"

echo "domain $DOMAIN" >$RESOLV
echo "nameserver $NAMESERVER" >>$RESOLV

#edit the rc.net script.
sed "s/#ROUTER#/ROUTER=$ROUTER/" <$RC >$TMPFILE
sed "s/#NET#/NET=$NET/" <$TMPFILE >$RC
rm -f $TMPFILE

#while [ "$ANSWER" != "y" -a "$ANSWER" != "Y" -a "$ANSWER" != "n" -a \
#	"$ANSWER" != "N" ]; do
#
#	echo -n "Run named at boot[y/n]? "
#	read ANSWER
#done
#
#if [ "$ANSWER" = "n" -o "$ANSWER" = "N" ]; then
#	mv $NAMED $NAMED.off
#else
#	echo "You will have to configure named yourself."
#fi
#
# now change rc.local.
if grep $RC $RCLOCAL; then
	echo "rc.net already run by rc.local. "
else
	echo -e "if [ -x $RC ]; then \n	$RC \n fi \n" | cat >>$RCLOCAL
fi