]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/dialog/samples/copifuncs/copi.sendifm1
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / dialog / samples / copifuncs / copi.sendifm1
1 #! /bin/sh
2 ##  $Revision: 1.1 $
3 ##  SH script to send UUCP batches out.
4
5 ##  =()<. @<_PATH_SHELLVARS>@>()=
6 . ~news/innshellvars
7
8 PROGNAME=`basename $0`
9 LOCK=${LOCKS}/LOCK.${PROGNAME}
10 LOG=${MOST_LOGS}/${PROGNAME}.log
11
12 MAXJOBS=200
13 UUXFLAGS="- -r -gd"
14
15 ##  Start logging.
16 test ! -f ${LOG} && touch ${LOG}
17 chmod 0660 ${LOG}
18 exec >>${LOG} 2>&1
19 echo "${PROGNAME}: [$$] begin `date`"
20 cd ${BATCH}
21
22 ##  Anyone else there?
23 trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
24 shlock -p $$ -f ${LOCK} || {
25     echo "${PROGNAME}: [$$] locked by [`cat ${LOCK}`]"
26     exit 0
27 }
28
29 ##  Who are we sending to?
30 if [ -n "$1" ] ; then
31     LIST="$*"
32 else
33     LIST=`ls /usr/spool/news/out.going|egrep "f[0-9]*.n[0-9]*$"`
34 fi
35
36 case ${HAVE_UUSTAT} in
37 DONT)
38     TEMP=${TMPDIR}/uuq$$
39     uuq -h |tr -d : >${TEMP}
40     ;;
41 esac
42
43 ##  Do the work...
44
45 for SITE in ${LIST}; do
46
47     ##  See if any data is ready for host.
48     BATCHFILE=${SITE}.uucp
49     if [ -f ${SITE}.work ] ; then
50         cat ${SITE}.work >>${BATCHFILE}
51         rm -f ${SITE}.work
52     fi
53     mv ${SITE} ${SITE}.work
54     ctlinnd -s -t30 flush ${SITE} || continue
55     cat ${SITE}.work >>${BATCHFILE}
56     rm -f ${SITE}.work
57     if [ ! -s ${BATCHFILE} ] ; then
58         echo "${PROGNAME}: [$$] no articles for ${SITE}"
59         rm -f ${BATCHFILE}
60         continue
61     fi
62
63     ##  Get the compression flags.
64     echo "${PROGNAME}: [$$] begin ${SITE}"
65     case "${SITE}" in
66     phreak)
67         COMPRESS="compress"
68         ;;
69     *)
70         COMPRESS="gzip"
71         ;;
72     esac
73
74     time batcher \