#!/bin/sh
#
# register - register for Duke programming contest
#
# Usage: register

address=contest@juliet.cs.duke.edu

echo Duke Internet Contest Registration

if test $# -ne 0; then
	echo Arguments ignored.
fi

echo 'Enter the name of your institution (e.g., "University of Fiji"):'
echo -n "> "
read institution

echo 'Enter the name of your team (e.g., "First Team"):'
echo -n "> "
read teamname

echo -n "Enter the name of the first team member: "
read member1

echo -n "Enter the name of the second team member (hit ENTER if none): "
read member2

echo -n "Enter the name of the third team member (hit ENTER if none): "
read member3

echo -n "Enter the name of the fourth team member (hit ENTER if none): "
read member4

echo "In which category do you wish to participate:"
echo '  1) Novice'
echo '  2) Expert, single member team'
echo '  3) Expert, multiple member team'
echo -n '> '
read category
case "$category" in
 1) class="I";;
 2) class="II";;
 3) class="III";;
 *) echo "Unknown category: $category"; exit 1;;
esac

echo ""
echo "Enter the email address where you receive contest mail."
echo "It should be fully specified (eg, myname@cs.school.edu):"
echo -n "> "
read email

echo ""
echo Institution: "$institution"
echo Team name: "$teamname"
echo Your team members:
echo "  $member1"
echo "  $member2"
echo "  $member3"
echo "  $member4"
echo "Class-$class team."
echo "Email address $email"

echo ""
echo -n 'Confirm registration (type "yes" to confirm): '
read confirm

if test "$confirm" = "yes"; then
Mail -s "register93" $address << EOF
TEAMNAME $teamname
AFFILIATION $institution
NAME1 $member1
NAME2 $member2
NAME3 $member3
NAME4 $member4
CLASS $class
ADDRESS $email
EOF
    echo Team registered. Please wait for a reply in the mail,
    echo at the above email address. It may take 5-20 minutes.
    echo Be patient. Please do NOT reregister.  Do not submit
    echo any programs to be judged before you are assigned a
    echo team number.
else
	echo Not registered. Try again, perhaps.
	exit 1
fi

echo ""
echo "Your system clock indicates that the time is:"
echo -n "    "
# if your system doesn't generate UTC time with the following command,
# uncomment the following line and comment out the "date -u" line
#TZ=GMT0 date
#date -u
contestdate.sh
echo "The contest begins when your system clock reaches:"
echo "    Thu Nov 18 23:00:00 GMT 1993"
