#! /bin/sh
umask 077
if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
	cat <<EOM
addsite: add a new site to feed
usage: addsite [-f] "sitename" "gup passwort" "email address for replies"
Be aware of the fact that the newsfeeds-file is not updated, but
must be brought up to date with gupdate
EOM
	exit 0
fi
# configuration variables
site=$1
passwd=$2
mail=$3
. /var/lib/news/gup/gupconfig
if [ -d $sitedir ] || grep -s "^$site[ \t]" $gupdir/config ; then
	echo "The directory $sitedir already exists or this host is already"
	echo "in your $gupdir/config file."
	exit 1
fi
mkdir -p $sitedir
ln -sf $defhdr $sitedir/header
ln -sf $deftrail $sitedir/trailer
sed -e "s/HOST/$site/g" $defgroup >$sitedir/groups
ln -sf $defexcl $sitedir/exclude
echo "creating new entry in config file"
echo "$site $passwd $mail" >>$gupdir/config
exit 0
