home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
300-399
/
ff319.lzh
/
CNewsSrc
/
cnews.orig.lzh
/
batch
/
sendbatches
< prev
next >
Wrap
Text File
|
1989-06-27
|
3KB
|
172 lines
#! /bin/sh
# Master batching control.
# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
. ${NEWSCONFIG-/usr/lib/news/bin/config}
PATH=$NEWSCTL/bin:$NEWSBIN/batch:$NEWSBIN:$NEWSPATH ; export PATH
umask $NEWSUMASK
origpath="$PATH"
parms=$NEWSCTL/batchparms
log=$NEWSCTL/batchlog # also same with suffixes .o and .oo
# lock against multiple simultaneous execution
lock="$NEWSCTL/LOCKbatch"
ltemp="$NEWSCTL/L.$$"
echo $$ >$ltemp
trap "rm -f $ltemp ; exit 0" 0 1 2 15
if newslock $ltemp $lock
then
trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
else
exit 0
fi
cd $NEWSARTS/out.going
# Determine what systems are being requested, in what order.
case "$1"
in
-d)
debug=yes
shift
;;
esac
case $#
in
0)
if egrep '^/default/[ ]' $parms >/dev/null # default line found
then
syses=`ls -tr | egrep -v '^[@.]'` # oldest first
else
syses="`egrep '^[^/#]' $parms | awk '{ print $1 }'`"
fi
;;
*)
syses="$*"
;;
esac
case $debug
in
yes)
for sys in $syses
do
echo $sys
done
exit 0
;;
esac
# Start up logging.
mv $log.o $log.oo
mv $log $log.o
date >$log
# Run through them.
for sys in $syses
do
# Move into his directory, include it in search path.
here=$NEWSARTS/out.going/$sys
if test ! -d $here
then
echo "$0: cannot find batch directory for \`$sys'" >>$log
continue
fi
cd $here
PATH=$here:$origpath ; export PATH
NEWSSITE=$sys ; export NEWSSITE # For site-specific programs.
# Is there anything to do?
files=`echo togo*`
if test "$files" = 'togo*' || test "$files" = "togo" -a ! -s togo
then
continue # no
fi
# Pick up the batchparms line.
ctlline="`egrep \"^$sys[ ]\" $parms | sed 1q`"
if test " $ctlline" = " "
then
ctlline="`egrep '^/default/[ ]' $parms | sed 1q`"
fi
set $ctlline
if test " $#" -ne 6
then
echo "$0: bad or missing batchparms line for \`$sys'" >>$log
continue
fi
batchsize=$2
limit=$3
batcher=$4
muncher=$5
sender=$6
# How many to send?
outstand=`queuelen $sys`
nbatch=`expr $limit - $outstand`
roomfor=`spacefor $batchsize outbound $sys`
if test " $nbatch" -gt " $roomfor"
then
nbatch=$roomfor
fi
# If not allowed to send, remember reason.
status='batches flowing'
if test " $nbatch" -le 0
then
if test " $roomfor" -le 0
then
status='disk too full for batching'
else
status='queue full, no recent movement'
fi
fi
# Try sending some.
while test " $nbatch" -gt 0
do
# Does he have batches prepared already?
if test "`echo togo.[0-9]`" = 'togo.[0-9]'
then
# No -- need some more batches.
if test ! -s togo && test ! -s togo.next
then
break # Nothing left to do.
fi
batchsplit $batchsize
fi
# Send some batches.
them=`ls | egrep '^togo\.[0-9]' | sed "${nbatch}q"`
for f in $them
do
if $batcher -d $NEWSARTS $f | $muncher | $sender $sys
then
rm $f
else
echo "$0: batching for \`$sys' failed" >>$log
exit 1
fi
done
ndone=`echo $them | wc -w`
nbatch=`expr $nbatch - $ndone`
# Recheck the space -- it can fall for other reasons.
roomfor=`spacefor $batchsize outbound $sys`
if test " $nbatch" -gt " $roomfor"
then
nbatch=$roomfor
fi
done
# Report status, if appropriate.
nart=`cat togo* | wc -l | awk '{print $1}'`
if test " $nart" -gt 0
then
echo "$sys backlog $nart ($status)" >>$log
fi
done