~abone/ubuntu/natty/popularity-contest/fix-742017

« back to all changes in this revision

Viewing changes to debian/cron.weekly

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2005-07-21 17:46:13 UTC
  • mfrom: (1.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050721174613-u3xtfc8ch68rwtwu
Tags: 1.30ubuntu1
* Resynchronise with Debian.
* debian/config: Default USEHTTP to true on upgrades.
* popcon-upload-ubuntu: Replace ubuntulinux.org with ubuntu.com.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
unset MAILTO
10
10
unset MY_HOSTID
11
11
unset PARTICIPATE
 
12
unset SUBMITURLS
 
13
unset USEHTTP
12
14
 
13
15
# get configuration information
14
16
. /usr/share/popularity-contest/default.conf
15
17
. /etc/popularity-contest.conf
16
18
 
 
19
# don't run if MAILTO address is blank!
 
20
if [ -z "$MAILTO" ]; then exit 0; fi
 
21
 
17
22
# don't run if PARTICIPATE is "no" or unset!
18
23
[ "$PARTICIPATE" = "no" ] || [ -z "$PARTICIPATE" ] && exit 0
19
24
 
21
26
cd /var/log
22
27
umask 022
23
28
savelog -c 7 popularity-contest >/dev/null
 
29
POPCON=/var/log/popularity-contest
24
30
 
25
31
run_popcon()
26
32
{
28
34
        HOME=/tmp su nobody -pc "sh -c /usr/sbin/popularity-contest"
29
35
}
30
36
 
31
 
# generate and transmit the popularity contest data
32
 
 
33
 
run_popcon \
34
 
        | tee /var/log/popularity-contest \
35
 
        | /usr/sbin/popcon-upload >/dev/null 2>&1
 
37
do_sendmail()
 
38
{
 
39
        if [ -n "$MAILFROM" ]; then
 
40
                sendmail -oi -f "$MAILFROM" "$MAILTO"
 
41
        else
 
42
                sendmail -oi "$MAILTO"
 
43
        fi
 
44
}
 
45
 
 
46
# generate the popularity contest data
 
47
 
 
48
run_popcon > $POPCON
 
49
 
 
50
SUBMITTED=no
 
51
 
 
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
 
57
                SUBMITTED=yes
 
58
        else
 
59
                logger -t popularity-contest "unable to submit report to $URL."
 
60
        fi
 
61
    done
 
62
fi
 
63
 
 
64
# try to email the popularity contest data
 
65
 
 
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" \
 
77
                            --to "$MAILTO" \
 
78
                            --header "From: <$MAILFROM>" \
 
79
                            --header "Sender: <$MAILFROM>" \
 
80
                            --output | do_sendmail
 
81
                else
 
82
                        gzip -9 < $POPCON | mime-construct \
 
83
                            --type application/x-popcon-compressed \
 
84
                            --encoding base64 --file - \
 
85
                            --subject "popularity-contest submission" \
 
86
                            --to "$MAILTO" \
 
87
                            --output | do_sendmail
 
88
                fi
 
89
        else
 
90
            # Not able to make compressed email, send uncompressed
 
91
            (
 
92
                if [ -n "$MAILFROM" ]; then
 
93
                        echo "From: <$MAILFROM>"
 
94
                        echo "Sender: <$MAILFROM>"
 
95
                fi
 
96
                echo "To: $MAILTO"
 
97
                echo "Subject: popularity-contest submission"
 
98
                echo "MIME-Version: 1.0"
 
99
                echo "Content-Type: text/plain"
 
100
                echo
 
101
                cat $POPCON
 
102
            ) | do_sendmail
 
103
        fi
 
104
        SUBMITTED=yes
 
105
    else
 
106
        logger -t popularity-contest "unable to submit report using sendmail."
 
107
    fi
 
108
fi
 
109
 
 
110
if [ "yes" != "$SUBMITTED" ] ; then
 
111
        logger -t popularity-contest "unable to submit report."
 
112
fi