13
15
# get configuration information
14
16
. /usr/share/popularity-contest/default.conf
15
17
. /etc/popularity-contest.conf
19
# don't run if MAILTO address is blank!
20
if [ -z "$MAILTO" ]; then exit 0; fi
17
22
# don't run if PARTICIPATE is "no" or unset!
18
23
[ "$PARTICIPATE" = "no" ] || [ -z "$PARTICIPATE" ] && exit 0
28
34
HOME=/tmp su nobody -pc "sh -c /usr/sbin/popularity-contest"
31
# generate and transmit the popularity contest data
34
| tee /var/log/popularity-contest \
35
| /usr/sbin/popcon-upload >/dev/null 2>&1
39
if [ -n "$MAILFROM" ]; then
40
sendmail -oi -f "$MAILFROM" "$MAILTO"
42
sendmail -oi "$MAILTO"
46
# generate the popularity contest data
52
# try to post the report through http POST
53
if [ "$SUBMITURLS" ] && [ "yes" = "$USEHTTP" ]; then
54
for URL in $SUBMITURLS ; do
55
if setsid /usr/share/popularity-contest/popcon-upload-ubuntu \
56
< $POPCON 2>/dev/null ; then
59
logger -t popularity-contest "unable to submit report to $URL."
64
# try to email the popularity contest data
66
if [ yes != "$SUBMITTED" ]; then
67
if [ -x "`which sendmail 2>/dev/null`" ]; then
68
# Sending compressed emails are disabled as the receiving end
69
# isn't implemented yet.
70
if false && [ -x "`which mime-construct 2>/dev/null`" ]; then
71
# Make compresssed email
72
if [ -n "$MAILFROM" ]; then
73
gzip -9 < $POPCON | mime-construct \
74
--type application/x-popcon-compressed \
75
--encoding base64 --file - \
76
--subject "popularity-contest submission" \
78
--header "From: <$MAILFROM>" \
79
--header "Sender: <$MAILFROM>" \
80
--output | do_sendmail
82
gzip -9 < $POPCON | mime-construct \
83
--type application/x-popcon-compressed \
84
--encoding base64 --file - \
85
--subject "popularity-contest submission" \
87
--output | do_sendmail
90
# Not able to make compressed email, send uncompressed
92
if [ -n "$MAILFROM" ]; then
93
echo "From: <$MAILFROM>"
94
echo "Sender: <$MAILFROM>"
97
echo "Subject: popularity-contest submission"
98
echo "MIME-Version: 1.0"
99
echo "Content-Type: text/plain"
106
logger -t popularity-contest "unable to submit report using sendmail."
110
if [ "yes" != "$SUBMITTED" ] ; then
111
logger -t popularity-contest "unable to submit report."