Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / etc / cron.daily / | server ip : 172.67.156.115 your ip : 108.162.241.19 H O M E |
Filename | /etc/cron.daily/popularity-contest |
Size | 2.36 kb |
Permission | rwxr-xr-x |
Owner | root : root |
Create time | 27-Apr-2025 09:56 |
Last modified | 13-May-2013 18:06 |
Last accessed | 08-Jul-2025 07:45 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
#!/bin/sh
# don't run if this package is removed but not purged
if [ ! -f /usr/sbin/popularity-contest ]; then
exit 0
fi
unset MAILFROM
unset MAILTO
unset MY_HOSTID
unset PARTICIPATE
unset SUBMITURLS
unset USEHTTP
unset MTAOPS
# get configuration information
. /usr/share/popularity-contest/default.conf
. /etc/popularity-contest.conf
# don't run if MAILTO address is blank, and not configured to use HTTP POST!
if [ -z "$MAILTO" ] && [ "yes" != "$USEHTTP" ]; then exit 0; fi
# don't run if PARTICIPATE is "no" or unset!
[ "$PARTICIPATE" = "no" ] || [ -z "$PARTICIPATE" ] && exit 0
if [ -n "$HTTP_PROXY" ]; then
export http_proxy="$HTTP_PROXY";
fi
POPCON=/var/log/popularity-contest
# Only run on the given day, to spread the load on the server a bit
if [ "$DAY" ] && [ "$DAY" != "$(date +%w)" ] ; then
# Ensure that popcon runs at least once in the last week
if [ -f "$POPCON" ] ; then
now=$(date +%s)
lastrun=$(date -r $POPCON +%s)
# 6.5 days, in seconds
week=561600
if [ "$(( $now - $lastrun ))" -le "$week" ]; then
exit 0
fi
fi
fi
# keep old logs
cd /var/log
umask 022
savelog -c 7 popularity-contest >/dev/null
run_popcon()
{
su -s /bin/sh -c "/usr/sbin/popularity-contest" nobody
}
do_sendmail()
{
if [ -n "$MAILFROM" ]; then
sendmail -oi $MTAOPS -f "$MAILFROM" $MAILTO
else
sendmail -oi $MTAOPS $MAILTO
fi
}
# generate the popularity contest data
run_popcon > $POPCON
SUBMITTED=no
# try to post the report through http POST
if [ "$SUBMITURLS" ] && [ "yes" = "$USEHTTP" ]; then
for URL in $SUBMITURLS ; do
if setsid /usr/share/popularity-contest/popcon-upload \
-u $URL -f $POPCON -C 2>/dev/null ; then
SUBMITTED=yes
else
logger -t popularity-contest "unable to submit report to $URL."
fi
done
fi
# try to email the popularity contest data
if [ yes != "$SUBMITTED" ] && [ -n "$MAILTO" ]; then
if [ -x "`which sendmail 2>/dev/null`" ]; then
(
if [ -n "$MAILFROM" ]; then
echo "From: <$MAILFROM>"
echo "Sender: <$MAILFROM>"
fi
echo "To: $MAILTO"
echo "Subject: popularity-contest submission"
echo "MIME-Version: 1.0"
echo "Content-Type: text/plain"
echo
cat $POPCON
) | do_sendmail
SUBMITTED=yes
else
logger -t popularity-contest "unable to submit report using sendmail."
fi
fi
if [ "yes" != "$SUBMITTED" ] ; then
logger -t popularity-contest "unable to submit report."
fi
# don't run if this package is removed but not purged
if [ ! -f /usr/sbin/popularity-contest ]; then
exit 0
fi
unset MAILFROM
unset MAILTO
unset MY_HOSTID
unset PARTICIPATE
unset SUBMITURLS
unset USEHTTP
unset MTAOPS
# get configuration information
. /usr/share/popularity-contest/default.conf
. /etc/popularity-contest.conf
# don't run if MAILTO address is blank, and not configured to use HTTP POST!
if [ -z "$MAILTO" ] && [ "yes" != "$USEHTTP" ]; then exit 0; fi
# don't run if PARTICIPATE is "no" or unset!
[ "$PARTICIPATE" = "no" ] || [ -z "$PARTICIPATE" ] && exit 0
if [ -n "$HTTP_PROXY" ]; then
export http_proxy="$HTTP_PROXY";
fi
POPCON=/var/log/popularity-contest
# Only run on the given day, to spread the load on the server a bit
if [ "$DAY" ] && [ "$DAY" != "$(date +%w)" ] ; then
# Ensure that popcon runs at least once in the last week
if [ -f "$POPCON" ] ; then
now=$(date +%s)
lastrun=$(date -r $POPCON +%s)
# 6.5 days, in seconds
week=561600
if [ "$(( $now - $lastrun ))" -le "$week" ]; then
exit 0
fi
fi
fi
# keep old logs
cd /var/log
umask 022
savelog -c 7 popularity-contest >/dev/null
run_popcon()
{
su -s /bin/sh -c "/usr/sbin/popularity-contest" nobody
}
do_sendmail()
{
if [ -n "$MAILFROM" ]; then
sendmail -oi $MTAOPS -f "$MAILFROM" $MAILTO
else
sendmail -oi $MTAOPS $MAILTO
fi
}
# generate the popularity contest data
run_popcon > $POPCON
SUBMITTED=no
# try to post the report through http POST
if [ "$SUBMITURLS" ] && [ "yes" = "$USEHTTP" ]; then
for URL in $SUBMITURLS ; do
if setsid /usr/share/popularity-contest/popcon-upload \
-u $URL -f $POPCON -C 2>/dev/null ; then
SUBMITTED=yes
else
logger -t popularity-contest "unable to submit report to $URL."
fi
done
fi
# try to email the popularity contest data
if [ yes != "$SUBMITTED" ] && [ -n "$MAILTO" ]; then
if [ -x "`which sendmail 2>/dev/null`" ]; then
(
if [ -n "$MAILFROM" ]; then
echo "From: <$MAILFROM>"
echo "Sender: <$MAILFROM>"
fi
echo "To: $MAILTO"
echo "Subject: popularity-contest submission"
echo "MIME-Version: 1.0"
echo "Content-Type: text/plain"
echo
cat $POPCON
) | do_sendmail
SUBMITTED=yes
else
logger -t popularity-contest "unable to submit report using sendmail."
fi
fi
if [ "yes" != "$SUBMITTED" ] ; then
logger -t popularity-contest "unable to submit report."
fi