#! /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.

CONFDIR=/usr/local/etc/s-news
SUCKDIR=$CONFDIR/suck
USER=news
GROUP=news
UMASK=022

options='';

while [ `echo "x$1" | cut -c1-2` = "x-" ]
do
	opt=`echo "$1" | cut -c2-`
	options="$options $opt"
	shift;
done

if [ "x$1" = "x" ]
then
	echo "Usage: $0 [<options>] <host> <groups...>"
	exit 1
fi

host=$1

while [ "x$2" != "x" ]
do
	echo -e "$host\t$2" >>$CONFDIR/newsfeeds
	shift 
done

if [ "x$UMASK" != "x" ]
then
	umask $UMASK
fi

if mkdir -p $SUCKDIR/$host
then
	echo junk >$SUCKDIR/$host/active-ignore
	# Uncomment the following line if you don't want cancel messages to propagate
	#echo control.cancel >>$SUCKDIR/$host/active-ignore
	mkdir $SUCKDIR/$host/incoming

	for opt in $options
	do
		echo $opt >> $SUCKDIR/$host/options
	done

	if [ "x$GROUP" != "x" ]
	then
		chgrp -R $GROUP $SUCKDIR/$host
	fi
	if [ "x$USER" != "x" ]
	then
		chown -R $USER $SUCKDIR/$host
	fi
fi
