: Feeding shell script for standard one-dir per site system

# The directory in which feeds are built
BATCHDIR=/lg/lib/news/feed
# The binary directory for feeding programs
FEEDBIN=/v/src/nl/lib
# The C News spacefor program.  If you run B news, get the C news
# spacefor distribution, or use the sample spacefor shell script to be
# found in this directory.   The C news QUEULEN program checks how many
# batches are queued up for the named site.
SPACEFOR=/v/bin/news/spacefor
QUEUELEN=/v/bin/news/queuelen

cd $BATCHDIR

# for each site

if test $# -gt 0 ; then
	ARGS=$*
 else
	ARGS=*
fi

for site in $ARGS ; do
	# skip non directories
	if test ! -d $site ; then
		continue
	fi

	cd $site

	# if there is a new subscription file, merge it in
	# new_feed can be created by permanent subscription file, too
	# The program 'subscribers' will link the permanent subscription
	# file to new_feed as often as you wish to run it.
	# (It's not done here since you probably only want to redo the
	# feed once/day or so.  You batch up more frequently)

	if test -r new_feed ; then
		if $FEEDBIN/rcmerge n=newsrc ../global_rules local_rules new_feed ; then
			rm -f new_feed
		 else
			echo "Update of .newsrc with new info failed."
		fi
	fi


	# generate an m= option
	roomfor=`$SPACEFOR 1000 outbound $site`
	if test " $roomfor" -le 50 ; then
		echo No room for batching to $site -- only $roomfor K
		continue
		fi
	# Check to see if queue is not too full -- C news style
	if test `$QUEUELEN $site` -gt 20 ; then
		echo Too many files batched up for $site
		continue
		fi

	if test -r options ; then
		read options <options
	 else
		options="n=newsrc"
	fi

	eval $FEEDBIN/feed -l $site $options m=$roomfor
	cd ..
done

