/usr/lib/news/bin/sendbatch is in inn 1:1.7.2q-41build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | #! /bin/sh
## $Revision: 1.14 $
## SH script to send UUCP batches out. By Mike Cooper and Rich $alz.
## Based on B News sendbatch 1.22 10/29/89.
## =()<. @<_PATH_SHELLVARS>@>()=
. /usr/lib/news/innshellvars
## Place to run a df, and amount of space needed.
UUSPOOL=/var/spool/uucp
SPOOLFREE=20000
## Program names and flags. Most can be set on the command-line.
C7=
COMP=
COMPFLAGS=
# Use the COMPRESS variable as it is in innshellvars
# COMPRESS=/usr/ucb/compress
ECHO=
## Not a config param since this is the remote rnews.
RNEWS=rnews
UUX=uux
UUXFLAGS="- -r -n -gd"
## Desired size of each batch, total number of bytes we want to queue.
DEFBYTES=50000
BYTESQUEUED=1000000000
PROG=`basename $0`
## Go to where the action is.
cd ${BATCH}
## Loop over command line.
for SITE
do
## Is this a flag?
case "${SITE}" in
-s*)
DEFBYTES=`expr "${SITE}" : '-s\(.*\)'`
continue
;;
-m*)
BYTESQUEUED=`expr "${SITE}" : '-m\(.*\)'`
continue
;;
+m)
BYTESQUEUED=''
continue
;;
-p*)
BYTESPERRUN=`expr "${SITE}" : '-p\(.*\)'`
continue
;;
+p)
BYTESPERRUN=''
continue
;;
-r*)
RNEWS=`expr "${SITE}" : '-r\(.*\)'`
continue
;;
-U*)
UUX=`expr "${SITE}" : '-U\(.*\)'`
continue
;;
-u*)
UUXFLAGS=`expr "${SITE}" : '-u\(.*\)'`
continue
;;
-c7)
COMP="; exec ${COMPRESS} ${COMPFLAGS} | $LIB/encode"
ECHO="echo '#! c7unbatch'"
continue
;;
-c)
COMP="; exec ${COMPRESS} ${COMPFLAGS}"
ECHO="echo '#! cunbatch'"
continue
;;
+c)
COMP=''
C7=''
ECHO=''
COMPFLAGS=''
continue
;;
-[bBC]*)
COMPFLAGS="${COMPFLAGS} ${SITE}"
continue
;;
-o*)
ECHO=`expr "${SITE}" : '-o\(.*\)'`
RNEWS='cunbatch'
continue
;;
+o)
ECHO=''
RNEWS=rnews
continue
;;
-D*)
UUSPOOL=`expr "${SITE}" : '-D\(.*\)'`
continue
;;
+D)
UUSPOOL=''
continue
;;
-f*)
SPOOLFREE=`expr "${SITE}" : '-f\(.*\)'`
continue
;;
esac
test -z "${BYTESPERRUN}" && BYTESPERRUN=${BYTESQUEUED}
## We have a site; lock it.
LOCK=${LOCKS}/LOCK.${SITE}
trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
shlock -p $$ -f ${LOCK} || {
echo "${PROG}: ${SITE} Locked by `cat ${LOCK}`."
continue
}
## Flush the batchfile.
BATCHFILE=${BATCH}/${SITE}.uucp
if [ -f ${SITE}.work ] ; then
cat ${SITE}.work >>${BATCHFILE}
rm -f ${SITE}.work
fi
mv ${SITE} ${SITE}.work
ctlinnd -s -t30 flush ${SITE} || {
echo "${PROG}: Can't flush ${SITE}."
rm -f ${LOCK}
continue
}
cat ${SITE}.work >>${BATCHFILE}
rm -f ${SITE}.work
if [ ! -s ${BATCHFILE} ] ; then
echo "${PROG}: No articles for ${SITE}."
rm -f ${LOCK}
continue
fi
## Check free space on the partition?
if [ -n "${UUSPOOL}" ] ; then
# FREE=`(cd ${UUSPOOL}; df . | ${AWK} '
# $6 == "'${UUSPOOL}'" { print $4 ; exit }
# $1 == "'${UUSPOOL}'" && NF == 7 { print $4 ; exit }
# $2 == "'${UUSPOOL}'" { print $5 ; exit }
# $1 == "'${UUSPOOL}'" { print $3 ; exit }
# ')`
## =()< POS=@<INNWATCH_BLOCKS>@>()=
POS=4
DOLLAR="$"
FREE=`${INNDF} ${UUSPOOL} | ${AWK} "/^\// { print ${DOLLAR}${POS}; exit }"`
if [ -n "${FREE}" -a "${FREE}" -lt ${SPOOLFREE} ] ; then
echo "${PROG}: No space on ${UUSPOOL} for ${SITE} (${FREE})."
rm -f ${LOCK}
continue
fi
fi
## Check the host's queue size?
QUEUE=0
if [ -n "${BYTESQUEUED}" ] ; then
if [ -d ${UUSPOOL}/${SITE} ] ; then
# Get queue size from directory size
QUEUE=`du -s "${UUSPOOL}/${SITE}" \
| ${AWK} '{ printf("%s000\n", $1); }'`
else
## Get queue size from uuq command.
QUEUE=`uuq -l -s${SITE} 2>/dev/null | ${AWK} '{print $4; exit }'`
fi
test -z "${QUEUE}" && QUEUE=0
if [ "${QUEUE}" -gt ${BYTESQUEUED} ] ; then
echo "${PROG}: ${SITE} has ${QUEUE} bytes queued."
rm -f ${LOCK}
continue
fi
fi
## Set how many bytes we can queue this time.
if [ -z "${BYTESQUEUED}" ] ; then
BATCHBYTES=${BYTESPERRUN}
else
BATCHBYTES=`expr ${BYTESQUEUED} - "${QUEUE}"`
test ${BATCHBYTES} -gt ${BYTESPERRUN} && BATCHBYTES=${BYTESPERRUN}
fi
# Say how big each batch should be. Assume 50% compression.
if [ -n "${COMP}" ] ; then
MAXBYTES=`expr ${DEFBYTES} \* 2`
else
MAXBYTES=${DEFBYTES}
fi
## Assemble uux command to have batcher(1) run.
if [ -f ${SITE}.cmd ] ; then
UUXCOM="`cat ${SITE}.cmd`"
elif [ -n "${ECHO}" -o -n "${COMP}" ]; then
UUXCOM="( ${ECHO} ${COMP} ) | ${UUX} - ${UUXFLAGS} ${SITE}!${RNEWS}"
else
UUXCOM="${UUX} - ${UUXFLAGS} ${SITE}!${RNEWS}"
fi
## Create batches.
if [ ${BATCHBYTES} -gt 0 ] ; then
${NEWSBIN}/batcher -B ${BATCHBYTES} -b ${MAXBYTES} -p "${UUXCOM}" \
${SITE} ${BATCHFILE}
fi
rm -f ${LOCK}
done
|