#!/bin/sh
##  SH script to send fido batches out trought ifmail.

set -e

VERBOSE=false
if [ -e /usr/lib/news/innshellvars ]; then
  . /usr/lib/news/innshellvars
else
  . /etc/news/innshellvars
fi
. /etc/ifmail/ifshellvars

if [ ! -f $SERVERPID ]; then exit ;fi

if [ $# -lt 1 ]; then
  echo "$0 [$$]: Usage: $0 site"
  exit 1
else
  SITE=$1
fi

if [ -s $BATCH/$SITE ]; then
  mv $BATCH/$SITE $BATCH/$SITE.work
  $NEWSBIN/ctlinnd -s -t30 flush $SITE
  $NEWSBIN/batcher -b0 -v -p\
    "$IFBIN/ifnews $2 $3 $4 $5 %s"\
    $SITE $BATCH/$SITE.work \
      && rm -f $BATCH/$SITE.work
else
  $VERBOSE && echo "$0 [$$]: no articles for $SITE"
fi

