# Copyright (c) 1996 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: questions.sh,v 1.32 1996/01/23 18:43:36 ghudson Exp ghudson $
#	$Source: /mit/netbsd/dev/install/server/RCS/questions.sh,v $

# /tmp/vars inputs:
#	on_mitnet	whether the machine is on MITnet

# /tmp/vars outputs
#	rootpw		encrypted root password
#	enable_toor	whether to enable the toor account
#	rootmail	where to forward root mail
#	mitnet_inst	whether to run MITnet installation
#	athena_inst	whether to run Athena installation
#	mail		whether to send configuration mail
#	mail_cc		where to cc configuration mail to
#	action		what to do after installing

. /tmp/vars
. /utils

echo ""
echo "You may now remove the floppy disk from its drive.  Remember to do so"
echo "before your machine reboots."
echo ""
echo "Before we do the actual installation, we have some questions to ask"
echo "about the way you want your system configured."
echo ""

rootpw="`/readpw 'Please enter a password for the superuser account (root): '`"

echo ""
echo "The alternate super user account (toor) is like root, but uses /bin/sh"
echo "instead of /bin/csh as its shell.  You may enable the toor account from"
echo "the installation with the same password as root, if desired."
echo ""
echo -n "Would you like to enable the toor account? [yes] "
yesno yes
enable_toor="$resp"

echo ""
echo "Please enter an email address where mail to root@$host.$domain should"
echo "be forwarded to.  Just press enter if you want root's mail to be spooled"
echo "locally in /var/mail/root."
echo ""
echo -n "To what email address should mail to root be forwarded? "
read rootmail

echo ""
if [ "$on_mitnet" = "yes" ]; then
	echo "Since your machine is on MITnet, you may wish to install several"
	echo "customizations relevant to MITnet machines during the"
	echo "installation.  These are a prerequisite for the Athena"
	echo "customizations, and involve the following changes:"
else
	echo "Your machine does not appear to be on MITnet; however, you may"
	echo "still optionally install the MITnet customizations, which will"
	echo "make the following changes to your system:"
fi
echo ""
echo "	* Name resolution will be set up for the mit.edu domain."
echo "	* Mail will be configured with outgoing mail using the MIT mail hubs."
echo "	* Outgoing mail messages will use @mit.edu for unqualified addresses."
echo "	* The routing and time daemons will be turned off."
echo "	* The name resolution and NFS client daemons will be turned on."
echo "	* /etc/hosts.equiv will be deleted."
echo "	* Services used on MITnet will be added to your /etc/services file."
echo "	* Your local time will be set to US Eastern time."
echo ""
echo -n "Would you like MITnet customizations installed? [$on_mitnet] "
yesno $on_mitnet
mitnet_inst="$resp"

if [ "$mitnet_inst" = "yes" ]; then
	echo ""
	if [ "$on_mitnet" = "yes" ]; then
		echo "You may also choose to install the AFS and Athena"
		echo "software, involving the following changes:"
	else
		echo "You do not appear to be on MITnet.  If you are, you may"
		echo "install the AFS and Athena software, involving the"
		echo "following changes:"
	fi
	echo ""
	echo "	* AFS software will be put in /usr/vice and /bin/athena."
	echo "	* Athena software will be put in /bin/athena and /etc/athena."
	echo "	* /srvd, /usr/athena, /usr/X11R6, /usr/andrew, /usr/src"
	echo "	  /emul will be created as symlinks pointing to the SIPB cell."
	echo "	* Kerberized login services will be added to your inetd.conf."
	echo "	* Your /etc/rc.local file will call the Athena startup script."
	echo "	* /etc/gettytab will use /bin/athena/login for logins."
	echo "	* Your kernel will use PCVT instead of pccons."
	echo "	* /etc/ttys will contain PCVT devices, including a disabled"
	echo "	  line to start X and xlogin, for when you have X configured."
	echo "	* Your floppy devices will become world-readable and writable."
	echo "	* The sample line in your /root/.klogin will be removed."
	echo "	* You will have the kernfs and procfs filesystems mounted."
	echo ""
	echo -n "Would you like AFS and Athena software installed? [$on_mitnet] "
	yesno $on_mitnet
	athena_inst="$resp"
else
	echo ""
	echo "Since you chose not to install the MITnet customizations, you"
	echo "cannot install the Athena and AFS software."
	echo ""
	athena_inst=no
fi

echo ""
echo "The SIPB would like to track NetBSD installations that used our script;"
echo "as such, we would like to receive automated mail with configuration"
echo "information about your system to help us better account for our"
echo "resources and to see how popular this script is."
echo ""
echo -n "May this script mail your configuration information to the SIPB? "
echo -n "[yes] "
yesno yes
mail="$resp"
if [ "$mail" = "yes" ]; then
	echo ""
	echo "If you would like the above configuration information sent to"
	echo "you as well, enter your username below.  Otherwise, just press"
	echo "return."
	echo ""
	echo -n "Where else would you like the mail sent? "
	read mail_cc
fi

echo ""
echo "Finally, what would you like to have happen when the install finishes?"
echo 'Enter "r" to have your machine reboot automatically, "h" to have your'
echo 'machine halt, or "s" to have your machine exit to a shell prompt.'
echo ""
echo -n "What should your machine do after installing? [reboot] "
action=""
while [ "$action" = "" ]; do
	getresp r
	case "$resp" in
		r*)	action=reboot	;;
		h*)	action=halt	;;
		s*)	action=exit	;;
		*)	echo -n 'Please enter "r", "h", or "s": [reboot] ' ;;
	esac
done

if [ -n "$rootmail" ]; then
	rootmail_disp="$rootmail"
else
	rootmail_disp="<not forwarded>"
fi

echo "Okay, please confirm your answers to these questions:"
echo ""
echo "toor account enabled:			$enable_toor"
echo "Root mail forwards to:			$rootmail_disp"
echo "MITnet customizations:			$mitnet_inst"
echo "Athena customizations:			$athena_inst"
echo "Mail configuration to SIPB:		$mail (also to: $mail_cc)"
echo "Action after installation:		$action"
echo ""
echo -n "Do you accept these values? [yes] "

getresp yes
case "$resp" in
y)
	;;
n)
	echo "Okay, trying again."
	exec /questions
esac

cat >> /tmp/vars << EOM
rootpw="$rootpw"
enable_toor="$enable_toor"
rootmail="$rootmail"
mitnet_inst="$mitnet_inst"
athena_inst="$athena_inst"
mail="$mail"
mail_cc="$mail_cc"
action="$action"
EOM

if [ "$athena_inst" = "yes" ]; then
	echo ""
	echo "Please press return and read the following license statement"
	echo "about the use of the AFS on your system."
	read dummy
	more /MIT_COPYRIGHT
fi

