File: send-nntp.in

package info (click to toggle)
inn2 2.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,720 kB
  • ctags: 8,983
  • sloc: ansic: 92,499; sh: 13,509; perl: 12,921; makefile: 2,985; yacc: 842; python: 342; lex: 255
file content (88 lines) | stat: -rw-r--r-- 1,903 bytes parent folder | download | duplicates (7)
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
#! /bin/sh
# fixscript will replace this line with code to load innshellvars

##  $Revision: 4115 $
##  SH script to send NNTP news out.

PROGNAME=`basename $0`
LOG=${MOST_LOGS}/${PROGNAME}.log

##  Go to where the action is, start logging
cd $BATCH
umask 002
DEBUG=""
if [ "X$1" = X-d ] ; then
    DEBUG="-d"
    shift
else
    test ! -f ${LOG} && touch ${LOG}
    chmod 0660 ${LOG}
    exec >>${LOG} 2>&1
fi

echo "${PROGNAME}: [$$] begin `date`"

##  List of sitename:hostname pairs to send to
if [ -n "$1" ] ; then
    LIST="$*"
else
    echo "${PROGNAME}: [$$] no sites specified" >&2
    exit 1
fi

##  Do the work...
for SITE in ${LIST}; do
    case $SITE in
    *:*)
	HOST=`expr $SITE : '.*:\(.*\)'`
	SITE=`expr $SITE : '\(.*\):.*'`
	;;
    *)
	HOST=$SITE
	;;
    esac
    case $HOST in
    *@*)
        PORT=`expr $HOST : '\(.*\)@.*'` 
        HOST=`expr $HOST : '.*@\(.*\)'`
        ;;
    *)  
        PORT=119
        ;;
    esac
    BATCHFILE=${SITE}.nntp
    LOCK=${LOCKS}/LOCK.${SITE}
    trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
    shlock -p $$ -f ${LOCK} || {
	echo "${PROGNAME}: [$$] ${SITE} locked by `cat ${LOCK}`"
	continue
    }

    ##  See if any data is ready for host.
    if [ -f ${SITE}.work ] ; then
	cat ${SITE}.work >>${BATCHFILE}
	rm -f ${SITE}.work
    fi
    if [ ! -f ${SITE} -o ! -s ${SITE} ] ; then
	if [ ! -f ${BATCHFILE} -o ! -s ${BATCHFILE} ] ; then
	    rm -f ${LOCK}
	    continue
	fi
    fi
    mv ${SITE} ${SITE}.work
    ctlinnd -s -t30 flush ${SITE} || continue
    cat ${SITE}.work >>${BATCHFILE}
    rm -f ${SITE}.work
    if [ ! -s ${BATCHFILE} ] ; then
	echo "${PROGNAME}: [$$] no articles for ${SITE}"
	rm -f ${BATCHFILE}
	continue
    fi

    echo "${PROGNAME}: [$$] begin ${SITE}"
    time innxmit ${DEBUG} -P ${PORT} ${HOST} ${BATCH}/${BATCHFILE}
    echo "${PROGNAME}: [$$] end ${SITE}"
    rm -f ${LOCK}
done

echo "${PROGNAME}: [$$] end   `date`"