#! /bin/sh
#
# @(#)setMAILPROG	1.2	LPS_UNX_COM	02/15/93
#
# Copyright 1993   Digital Equipment Corporation, Maynard, MA
#
# setMAILPROG
#
# A script that produces a value for attribute MAILPROG.
#
# Parameters:
#    $1 - LPS class identifier, one of {PC, MC, PS, ENV}
#    $2 - Operating system type identifier (eg: SV2, BSD, etc)
#    $3 - Print client type identifier (eg: AIX, BSD, SV3, etc)
#    $4 - PrintServer printer model (eg: LPS17, LPS20)
#    $5 - Default value for the attribute
#    $6 - Path of the output file to receive the final attribute value
#
# Global variables:
#    ECHON
#    FUNCS
#    ENV_MAILADMADDRS
#    ENV_MAILOPTS
#    PAGER
#    PRODUCT
#
# Exit values:
#    0 - Success, output file contains newly set attribute value.
#    1 - Error or interruption occurred, error messages go to stderr,
#	 contents of the output file are undefined.
###

CLASS=$1
OSTYPE=$2
PCTYPE=$3
PSMODEL=$4
DEFVAL=$5
OUTFILE=$6

. $FUNCS   # Import the standard LPS shell functions

if [ "$CLASS" = "ENV" ]
then
   NOTES="
It is STRONGLY RECOMMENDED that you choose the default response for
this question."
fi

showhelp true "
Which mail program should be used to send electronic mail messages?

You can specify any existing mail program to send electronic messages.
However, be forewarned that specifying any mail program other than the
default program ($DEFVAL) may result in the failure to send mail
messages within some supporting programs and/or scripts.

The response to this question is validated by sending \"$ENV_MAILADMADDRS\"
a test mail message.  You do not have to review the test message to
continue the installation; instead, its only purpose is to test the
success of the mail program itself.
$NOTES"

while true
do
    getpath x $DEFVAL "Mail program"

    $ECHON "Testing mail program $RESPONSE ... "

    if $RESPONSE $ENV_MAILOPTS -s "Test message" "$ENV_MAILADMADDRS" << EOF

This is a test of sending a mail message using the $RESPONSE mail
program directly from the $PRODUCT.

You may delete this message at any time.
EOF
    then
	echo "done."
	break
    else
	echo
	echo
	echo "    For some reason the test of the specified mail program"
	echo "    did not succeed.  Please enter a different program path,"
	echo "    or press CTRL/C to abort the procedure."
    fi
done

echo "$RESPONSE" > $OUTFILE

exit 0
