#! /bin/ksh

PGM=`basename $0`

if test "$1" = "-d"
then
	debug=true
	logfile=/dev/null
	shift;
else
	debug=false
	logfile=$PGM.log
fi

if test $# -lt 5
then
	echo "Usage: $PGM listname description password header owner..."
	exit 1
fi

listname="$1"; shift;
listdesc="$1"; shift;
listpswd="$1"; shift;
listhead="$1"; shift;

SIG=SIGCHI
support=support@acm.org
infodir="instone@cs.bgsu.edu (Keith Instone, SIGCHI Information Director)"
mailman="perlman@turing.acm.org (Gary Perlman, SIGCHI Email Manager)"
listman="clore@acm.org (Michael Clore, ACM Network Information Manager)"
to=`echo "$support $infodir $mailman $*" | sed 's/([^)]*)//g'`
newline="
"

mail="/bin/mail $to"

if test "$debug" = "true"
then
	to=perlman
	mail=more
fi

if test ! -r $listhead
then
	echo "$PGM: Can't read header file: $listhead"
	echo "	No list request submitted"
	exit 2
fi

(
echo "====================== $PGM `date`"
echo "Sending request to:    $to"
echo "For a new list called: $listname $listdesc"
n=1
for owner
do
	echo "With listowner $n:      $owner"
	let n=$n+1
done
echo "With initial password: $listpswd"
echo "With header in file:   $listhead"
) | tee -a $logfile

n=1
for owner
do
	if test "$n" -eq 1
	then
		listownr="* Owner= $owner$newline* Owner= Quiet:"
	else
		listownr="$listownr$newline* Owner= $owner"
	fi
	let n=$n+1
done

$mail << EOF
Subject: $SIG list: $listname creation request

Please create a new $SIG LISTSERV list:
	$listname@acm.org

Please make the password for the list: $listpswd

In addition to the list $listname@acm.org,
please make sure that the forwarding aliases are set up:
	$listname-request@acm.org -> $listname-request@listserv.acm.org
	owner-$listname@acm.org   -> owner-$listname@listserv.acm.org
We realize that the creation of these aliases may generate
some automatic messages-to-members to the list owners.

Note that $SIG lists use a dash "-" as delimiter.

Please use the following list header to initialize the options:

* ACM $SIG $listdesc
*
$listownr
* Owner= $mailman
* Owner= $infodir
* Owner= $listman
`cat $listhead`
EOF
