# install script for the net.  First it should add the hostname to
# /etc hosts.
CONFIG=/usr/etc/ifconfig
HOSTS=/etc/hosts
INETD=/usr/etc/inetd
RC=/etc/rc.net
RESOLV=/etc/resolv.conf
ROUTE=/usr/etc/route

HOSTNAME=`/bin/hostname`
if [ "$HOSTNAME" = "linux" ];then
 echo "If you really want your hostname to be 'linux', type 'Y'."
 echo -n "Otherwise type your hostname: "
 read answer
 if [ "$answer" = "y" -o "$answer" = "Y" ];then :;else HOSTNAME=$answer;fi;fi
echo $HOSTNAME >/etc/HOSTNAME
/bin/hostname -Sv

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

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

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

/bin/rm -f $RC
/bin/cat <<EOF >$RC
# $RC
# Linux networking startup script.  Should be run by /etc/rc.local at
# boot time.  Configures the interfaces and starts the deamons.
# It assumes hostname has been set.
#
#
CONFIG=$CONFIG
INETD=$INETD
ROUTE=$ROUTE

HOSTNAME=\`/bin/hostname\`

# You may need to add a /usr/etc/ifsetup command to set the parameters
# for your ethernet card.

\$CONFIG lo 127.0.0.1
\$CONFIG eth0 netmask 255.255.255.0 \$HOSTNAME
\$ROUTE add loopback
\$ROUTE add \$HOSTNAME
\$ROUTE add default gw $GATEWAY metric 1

if [ -x \$INETD ]; then
	echo starting \$INETD
	\$INETD
fi
EOF

if [ -f $HOSTS ];then mv $HOSTS $HOSTS.OLD;fi
echo "# next two lines added by install.net" >>$HOSTS
echo "127.0.0.1	loopback" >>$HOSTS
echo "$IPADDRESS	$HOSTNAME.$DOMAIN $HOSTNAME" >>$HOSTS

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

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

chown bin.bin $HOSTS $RESOLV $RC
chmod 644 $HOSTS $RESOLV
chmod 744 $RC

echo "Networking software is now installed.  To start networking,"
echo "type '/etc/rc.net'.  This will be done automatically whenever"
echo "you reboot your machine."
#
