3
# $Id: lr_rawmail2mail.in,v 1.15 2001/10/18 19:13:17 flacoste Exp $
6
# Copyright (C) 2000-2001 Stichting LogReport Foundation LogReport@LogReport.org
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program (see COPYING); if not, check with
20
# http://www.gnu.org/copyleft/gpl.html or write to the Free Software
21
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24
PROGRAM=lr_rawmail2mail
25
identifier=${LR_ID:-UNSET}
26
tag="all all $identifier $PROGRAM"
30
echo >&2 "$tag err please give 2 args, indicating dumpstem addressee"
31
# when running directly from .qmail:
32
# exit 100 : hard error
33
# exit 111 : soft error
38
# dereference sysconfdir's prefix dependency
40
etcdir="@sysconfdir@/@PACKAGE@"
44
. $etcdir/profile_lean
48
echo >&2 "$tag err TMPDIR not set. did you source sysconfdir/defaults?"
52
if test ! -d "$TMPDIR"
54
echo >&2 "$tag notice dir $TMPDIR does not exist, creating it"
59
echo >&2 "$tag err cannot create $TMPDIR, exiting"
68
MAILFILE=$TMPDIR/$PROGRAM.$$.mail
71
SHFILE=$TMPDIR/$PROGRAM.$$.sh
72
# this sets lr_getbody_BODYFILE, lr_getbody_SUBJECTFILE
73
# and lr_getbody_SUBMITTER
74
if lr_getbody -i $identifier -f $MAILFILE > $SHFILE
79
echo >&2 "$tag err lr_getbody -i $identifier -f $MAILFILE failed"
80
echo >&2 "$tag notice keeping $MAILFILE and $SHFILE for debug"
84
REPORTFILE=$TMPDIR/$PROGRAM.$$.report
86
# SunOS's grep doesn't grok -q
87
if grep '^\[LogReport\]' < $lr_getbody_SUBJECTFILE > /dev/null
89
echo >&2 "$tag info file $MAILFILE seems to be a message from LogReport"
90
if grep ' notes on ' < $lr_getbody_SUBJECTFILE > /dev/null
92
# skip the explanation messages
95
echo >&2 "$tag info file $lr_getbody_BODYFILE contains a raw xml report"
96
# this does NOT exit when lr_xml2ascii exits unsuccessfully... XXX
97
lr_deanonimize $DUMPSTEM < $lr_getbody_BODYFILE | lr_xml2ascii \
100
echo >&2 "$tag info gonna sent $REPORTFILE to $TO"
102
# create new mailfile
104
# get evil stuff out of lr_getbody_SUBJECTFILE
105
sed 's/[^-_\.:a-zA-Z0-9 ]//g' $lr_getbody_SUBJECTFILE | head -1 \
106
> $TMPDIR/$PROGRAM.$$.tmp
107
mv $TMPDIR/$PROGRAM.$$.tmp $lr_getbody_SUBJECTFILE
108
SUBJECT=`cat $lr_getbody_SUBJECTFILE`
112
Subject: [LogReport] deanonimized report (was: $SUBJECT)
115
} | cat - $REPORTFILE > $MAILFILE
119
echo >&2 "$tag err writing $MAILFILE failed"
123
if @PATHTOSENDMAIL@ -t < $MAILFILE
127
echo >&2 "$tag err sendmail failed"
133
echo >&2 "$tag notice keeping $REPORTFILE on your request. remove manually."
142
echo >&2 "$tag notice keeping $MAILFILE on your request. remove manually."
143
echo >&2 "$tag notice keeping $lr_getbody_SUBJECTFILE on your request. remove manually."
144
echo >&2 "$tag notice keeping $lr_getbody_BODYFILE on your request. remove manually."
147
rm -f $lr_getbody_SUBJECTFILE
148
rm -f $lr_getbody_BODYFILE