chiark / gitweb /
strip out some system headers, caused trouble during my testing
[modbot-mtm.git] / inews.INO
1 #!/bin/sh
2 set -e
3
4 export NNTPSERVER=nnrp.chiark.greenend.org.uk
5 export NNTPAUTH='md5cookie1way chiark'
6
7 trap 'rm -f "$tf"' 0
8
9 tf=`mktemp`
10
11 sed '${ /^$/d }' >$tf
12
13 set +e
14 output=`
15         set -e
16         exec 2>&1
17         if [ x%DIVERTPOSTINGS% = x ]; then
18                 perl -pe '
19                         next unless ($.==1)../^$/;
20  s/^(?:X-Trace|NNTP-Posting-(?:Date|Host)|X-Complaints-To|Injection-Info)/X-$&/;
21                 ' $tf | inews -h -Q -R
22         else
23                 (set -e
24                  echo "Newsgroups: %DIVERTPOSTINGS%"
25                  sed 's/^Newsgroups:/X-Would-Newsgroups:/' $tf) | inews -h
26         fi
27 `
28 rc=$?
29 set -e
30
31 if [ $rc = 0 ]
32 then
33         echo 'posted ok!'
34         %BASEDIR%/xlog/bin/record posted %GROUP% <$tf
35         exit 0
36 fi
37
38 (
39         printf "Errors: %s" "$output"
40         echo
41         echo ======================
42         cat $tf
43 ) | mail -s "lost moderated newsgroup submission %ABBREV%" webstump