File: controlbatch.in

package info (click to toggle)
inn2 2.2.2.2000.01.31-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,424 kB
  • ctags: 5,722
  • sloc: ansic: 61,219; perl: 9,939; sh: 5,644; makefile: 1,695; awk: 1,567; yacc: 1,548; lex: 249; tcl: 3
file content (92 lines) | stat: -rw-r--r-- 2,601 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!@_PATH_SH@
########################################################################
# controlbatch - Run controlchan against a batch file.
#
# Command usage:  controlbatch [feedsite batchfile]
# Defaults are feedsite: controlchan!, batchfile: ${BATCH}/controlchan!
########################################################################
#
# This script will run controlchan against a batch file.  You can use
# it to clear occasional backlogs while running controls from a
# channel, or even skip the channel and run control messages as a file
# feed.
#
########################################################################
#
# If you're doing the channel thing, you might want to put something
# like this in your crontab to do a cleanup in the wee hours:
#
#	00 04 * * *	@prefix@/bin/controlbatch
#
########################################################################
#
# If you would rather skip the channel and just process controls each
# hour in a batch, use this newsfeeds entry instead of the "stock"
# version:
#
# controlchan!\
#	:!*,control,control.*,!control.cancel\
#	:Tf,Wnsm:
#
# And, a crontab entry something like this:
#
#	30 * * * *     @prefix@/bin/controlbatch
#
########################################################################

## Change this to point at *your* innshellvars ##
. @LIBDIR@/innshellvars


batchlock="${LOCKS}/LOCK.controlbatch"
mypid=$$

# A concession to INN 1.x
if [ me${PATHBIN}ow = meow ] ; then
	PATHBIN=${NEWSBIN}
	export PATHBIN
fi

# See if we have no arguments and should use the defaults. If there are
# arguments, make sure we have enough to attempt something useful.
if [ me${1}ow != meow ] ; then
	if [ me${2}ow = meow ] ; then
		echo "Usage: ${0} [feedsite batchfile]" >&2
		exit 0
	else
		feedsite=${1}
		batchfile=${2}
	fi
else
	feedsite=controlchan\!
	batchfile=controlchan\!
fi

# Check if any other copies of controlbatch are running.  If we are not
# alone, give up here and now.
${PATHBIN}/shlock -p $mypid -f ${batchlock} || exit 0

cd ${BATCH}

if [ -s ${batchfile}.work ] ; then
	cat ${batchfile}.work >>${batchfile}.doit
	rm -f ${batchfile}.work
fi

if [ -s ${batchfile} ] ; then
	mv ${batchfile} ${batchfile}.work
	if ${PATHBIN}/ctlinnd -s -t30 flush ${feedsite} ; then
		cat ${batchfile}.work >>${batchfile}.doit
		rm -f ${batchfile}.work
	fi
fi

if [ -s ${batchfile}.doit ] ; then
	${PATHBIN}/controlchan \
		< ${batchfile}.doit >> ${MOST_LOGS}/controlbatch.log 2>&1
	# if you want extra assurance that nothing gets lost...
	# cat ${batchfile}.doit >> ${batchfile}.done
	rm -f ${batchfile}.doit
fi

rm -f ${batchlock}