# Copyright (c) 1995 by the Student Information Processing Board
# 	  of the Massachusetts Institute of Technology
#  
# Permission to use, copy, modify, and distribute this software
# and its documentation for any purpose and without fee is
# hereby granted, provided that the above copyright notice
# appear in all copies and that both that copyright notice and
# this permission notice appear in supporting documentation,
# and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
# used in advertising or publicity pertaining to distribution
# of the software without specific, written prior permission.
# M.I.T. and the M.I.T. S.I.P.B. make no representations about
# the suitability of this software for any purpose.  It is
# provided "as is" without express or implied warranty.
#
#	$Id: config.sh,v 1.19 1995/12/25 07:28:38 ghudson Exp ghudson $
#	$Source: /mit/netbsd/dev/install/server/RCS/config.sh,v $

# /tmp/vars inputs:
#	disk		disk device containing NetBSD partition
#	u1letter	letter of /u1 subpartition
#	host		unqualified hostname of this system
#	domain		domain name of this system
#	intf		network interface device
#	ifaddr		IP address of network interface
#	ifnetmask	netmask of network interface
#	ifbcast		broadcast address of network interface
#	ifflags		flags of network interface
#	ifgateway	gateway address of subnet
#	on_mitnet	whether the machine is on MITnet
#	rootpw		encrypted root password
#	enable_toor	whether to enable the toor account
#	rootmail	where to forward root mail

. /tmp/vars
. /utils

echo -n "Creating configuration files... "
echo "/dev/${disk}a / ufs rw 1 1" > /mnt/etc/fstab
echo "/dev/${disk}${u1letter} /u1 ufs rw 1 1" >> /mnt/etc/fstab
if [ "$u1letter" = f ]; then
	echo "/dev/${disk}e /u1/usr/vice/cache ufs rw 1 1" >> /mnt/etc/fstab
fi
echo $host > /mnt/etc/myname
echo	"127.0.0.1	localhost localhost.$domain" > /mnt/etc/hosts
echo "$ifaddr	$host.$domain $host" >> /mnt/etc/hosts
echo "$ifgateway" > /mnt/etc/mygate
echo "inet $host.$domain $ifnetmask $ifbcast $ifflags" \
	> /mnt/etc/hostname.$intf
sync
echo "done."

echo -n "Setting root password... "
ed -s /mnt/etc/master.passwd << EOM
/^root/s:root\::root\:${rootpw}:
w
q
EOM
if [ "$enable_toor" = "yes" ]; then
	ed -s /mnt/etc/master.passwd << EOM
/^toor/s:toor\:\*:toor\:${rootpw}:
w
q
EOM
fi
echo "done."
chroot /mnt pwd_mkdb -p /etc/master.passwd

echo -n "Setting up root mail forwarding... "
if [ -n "$rootmail" ]; then
	ed -s /mnt/etc/aliases << EOS
/root:/c
root: $rootmail
.
w
q
EOS
else
	ed -s /mnt/etc/aliases << EOS
/root:/c
# root:
.
w
q
EOS
fi
echo "done."
chroot /mnt newaliases

sync

