#! /bin/sh
#
# S-News version 0.1.11 - A Simple News Server
# Copyright (C) 1998 Christopher John Purnell
#                    cjp@lost.org.uk
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

prefix=/usr/local
exec_prefix=${prefix}

BINDIR=${exec_prefix}/sbin
CONFDIR=/usr/local/etc/s-news
SPOOLDIR=/var/spool/s-news

SUCK=suck
RPOST=rpost

SUCKDIR=$CONFDIR/suck
SCRIPT=$CONFDIR/put.news
OUTFILE=/tmp/tmp$$

LOCALHOST=localhost

for host in `sed -e 's/#.*//' -e '/^$/d' $CONFDIR/newsfeeds | cut -f1 | uniq`
do
	dir=$SUCKDIR/$host
	if [ -d $dir ]
	then
		popts='';
		sopts='';
		if [ -f $dir/options ]
		then
			while read opt
			do
				case $opt in
				ssl)
					popts="$popts -z"
					sopts="$sopts -ssl"
				;;
				esac
			done < $dir/options
		fi
		if [ -f $dir/outgoing ]
		then
			 $RPOST $host -d -b $dir/outgoing -p $SPOOLDIR $popts -f \$\$o=$OUTFILE $SCRIPT \$\$i $OUTFILE
		fi
		$BINDIR/listactive $host > $dir/active
		$SUCK $host -c -AL $dir/active -bp -hl $LOCALHOST -dd $dir -dt $dir -dm $dir/incoming $sopts
	fi
done

$BINDIR/overview
