archie/release/B/scripts/mail_inform
2024-05-28 16:48:29 +02:00

75 lines
938 B
Bash
Executable File

#!/bin/sh -u
#
# We handle the output, from the telnet and e-mail clients, that is to
# be mailed to the user.
#
prog=`basename $0`
REPLY_ADDR='archie-group@bunyip.com'
usage()
{
cat - <<EOC
Usage: $0 email-addr filename
EOC
exit 1
}
fatal()
{
echo ""
echo "${prog}: $1"
exit 1
}
if [ $# -ne 2 ] ; then
usage
fi
do_trap ()
{
echo "${prog}: caught trap!" 1>&2
failure
}
failure ()
{
echo "${prog}: cleaning up and exiting." 1>&2
rm -f $info $mhead $data $part.*
exit 1
}
# ----------------- Configure ----------------------
#
# The path must include:
#
# - your mailer ($mailcmd) (e.g. /usr/lib/sendmail)
# - cat
# - echo
# - wc
# - grep
# - rm
PATH=/usr/bin:/usr/ucb:/usr/lib:bin
tmp=/tmp
# Must use quotes
mailcmd="sendmail -t -f$REPLY_ADDR"
# --------------- End Configure --------------------
umask 077
trap do_trap 1 2 3 15
if [ -r $2 ] ; then
cat $2| $mailcmd $1
fi
exit 0