#! /bin/sh
#
# $Header: /usr/local/libdata/cvs/simons/petidomo/scripts/list2news,v 1.1 1997/12/01 18:10:00 simons Exp $
#
# This script is intended to be run as posting filter for a mailing
# list. It will not modify the article, which is delivered on the list
# itself, but it will post a copy to the article to the newsgroup
# specified on the command line.
#
# Usage: list2news newsgroup
#

## Please customize these variables to your setup. ##

INEWS='~news/bin/inews -h'
TMPDIR=/tmp
FEEDNAME=$1@your.host.net

## The code below this line should not need any changes. ##

TMPFILE=${TMPDIR}/list2news.$$
TMPFILE2=${TMPDIR}/list2news2.$$

if [ \! $# -eq 1 ]; then
    echo Wrong command line syntax.
    echo Usage: $0 newsgroup
    exit 1;
fi

cat >${TMPFILE}
echo >${TMPFILE2} Path: ${FEEDNAME}
echo >>${TMPFILE2} Newsgroups: $1

sed <${TMPFILE} \
    -e '1d' \
    -e '2,/^$/ {
	/^[Rr][Ee][Cc][Ee][Ii][Vv][Ee][Dd]:*/d
    }' >>${TMPFILE2}

# In case you have problems with inews, just use the second form of
# the INEWS-command, to receive inews' error output as mail.
#
#(cat ${TMPFILE2} | ${INEWS} | mail -s inews-error petidomo-manager) >/dev/null 2>&1 &
(cat ${TMPFILE2} | ${INEWS}) >/dev/null 2>&1 &

cat ${TMPFILE}
rm -f ${TMPFILE} ${TMPFILE2}
exit 0
