2 # fixscript will replace this line with code to load innshellvars
4 ########################################################################
5 # controlbatch - Run controlchan against a batch file.
7 # Command usage: controlbatch [feedsite batchfile]
8 # Defaults are feedsite: controlchan!, batchfile: ${BATCH}/controlchan!
9 ########################################################################
11 # This script will run controlchan against a batch file. You can use
12 # it to clear occasional backlogs while running controls from a
13 # channel, or even skip the channel and run control messages as a file
16 ########################################################################
18 # If you're doing the channel thing, you might want to put something
19 # like this in your crontab to do a cleanup in the wee hours:
21 # 00 04 * * * @prefix@/bin/controlbatch
23 ########################################################################
25 # If you would rather skip the channel and just process controls each
26 # hour in a batch, use this newsfeeds entry instead of the "stock"
30 # :!*,control,control.*,!control.cancel\
33 # And, a crontab entry something like this:
35 # 30 * * * * @prefix@/bin/controlbatch
37 ########################################################################
39 batchlock="${LOCKS}/LOCK.controlbatch"
42 # A concession to INN 1.x
43 if [ me${PATHBIN}ow = meow ] ; then
48 # See if we have no arguments and should use the defaults. If there are
49 # arguments, make sure we have enough to attempt something useful.
50 if [ me${1}ow != meow ] ; then
51 if [ me${2}ow = meow ] ; then
52 echo "Usage: ${0} [feedsite batchfile]" >&2
59 feedsite=controlchan\!
60 batchfile=controlchan\!
63 # Check if any other copies of controlbatch are running. If we are not
64 # alone, give up here and now.
65 ${PATHBIN}/shlock -p $mypid -f ${batchlock} || exit 0
69 if [ -s ${batchfile}.work ] ; then
70 cat ${batchfile}.work >>${batchfile}.doit
71 rm -f ${batchfile}.work
74 if [ -s ${batchfile} ] ; then
75 mv ${batchfile} ${batchfile}.work
76 if ${PATHBIN}/ctlinnd -s -t30 flush ${feedsite} ; then
77 cat ${batchfile}.work >>${batchfile}.doit
78 rm -f ${batchfile}.work
82 if [ -s ${batchfile}.doit ] ; then
83 ${PATHBIN}/controlchan \
84 < ${batchfile}.doit >> ${MOST_LOGS}/controlbatch.log 2>&1
85 # if you want extra assurance that nothing gets lost...
86 # cat ${batchfile}.doit >> ${batchfile}.done
87 rm -f ${batchfile}.doit