PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/dialog/samples/copifuncs/copi.sendifm1

https://bitbucket.org/freebsd/freebsd-head/
Shell | 74 lines | 52 code | 12 blank | 10 comment | 8 complexity | e24461b4ca50244d8142d7676474f90d MD5 | raw file
 1#! /bin/sh
 2##  $Revision: 1.1 $
 3##  SH script to send UUCP batches out.
 4
 5##  =()<. @<_PATH_SHELLVARS>@>()=
 6. ~news/innshellvars
 7
 8PROGNAME=`basename $0`
 9LOCK=${LOCKS}/LOCK.${PROGNAME}
10LOG=${MOST_LOGS}/${PROGNAME}.log
11
12MAXJOBS=200
13UUXFLAGS="- -r -gd"
14
15##  Start logging.
16test ! -f ${LOG} && touch ${LOG}
17chmod 0660 ${LOG}
18exec >>${LOG} 2>&1
19echo "${PROGNAME}: [$$] begin `date`"
20cd ${BATCH}
21
22##  Anyone else there?
23trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
24shlock -p $$ -f ${LOCK} || {
25    echo "${PROGNAME}: [$$] locked by [`cat ${LOCK}`]"
26    exit 0
27}
28
29##  Who are we sending to?
30if [ -n "$1" ] ; then
31    LIST="$*"
32else
33    LIST=`ls /usr/spool/news/out.going|egrep "f[0-9]*.n[0-9]*$"`
34fi
35
36case ${HAVE_UUSTAT} in
37DONT)
38    TEMP=${TMPDIR}/uuq$$
39    uuq -h |tr -d : >${TEMP}
40    ;;
41esac
42
43##  Do the work...
44
45for 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 \