|
|
@ -6,6 +6,8 @@ if [ ! -f /usr/sbin/popularity-contest ]; then |
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
|
|
|
|
MODE="$1" |
|
|
|
|
|
|
|
unset MAILFROM |
|
|
|
unset MAILTO |
|
|
|
unset MY_HOSTID |
|
|
@ -35,16 +37,22 @@ if [ -n "$HTTP_PROXY" ]; then |
|
|
|
export http_proxy="$HTTP_PROXY"; |
|
|
|
fi |
|
|
|
|
|
|
|
POPCON=/var/log/popularity-contest |
|
|
|
POPCONOLD=/var/log/popularity-contest |
|
|
|
POPCON=/var/log/popularity-contest.new |
|
|
|
|
|
|
|
# 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 |
|
|
|
if [ -f "$POPCONOLD" ] ; then |
|
|
|
now=$(date +%s) |
|
|
|
lastrun=$(date -r $POPCON +%s) |
|
|
|
# 6.5 days, in seconds |
|
|
|
week=561600 |
|
|
|
lastrun=$(date -r $POPCONOLD +%s) |
|
|
|
if [ "$MODE" = "--crond" ]; then |
|
|
|
# 6.5 days, in seconds |
|
|
|
week=561600 |
|
|
|
else |
|
|
|
# 7.5 days, in seconds |
|
|
|
week=648000 |
|
|
|
fi |
|
|
|
if [ "$(( $now - $lastrun ))" -le "$week" ]; then |
|
|
|
exit 0 |
|
|
|
fi |
|
|
@ -109,11 +117,11 @@ fi |
|
|
|
|
|
|
|
# try to email the popularity contest data |
|
|
|
|
|
|
|
if [ yes != "$SUBMITTED" ] && [ "$MAILTO" ]; then |
|
|
|
if [ "$MODE" = "--crond" ] && [ yes != "$SUBMITTED" ] && [ "$MAILTO" ]; then |
|
|
|
if [ -x "`which sendmail 2>/dev/null`" ]; then |
|
|
|
( |
|
|
|
if [ -n "$MAILFROM" ]; then |
|
|
|
echo "From: <$MAILFROM>" |
|
|
|
echo "From: <$MAILFROM>" |
|
|
|
echo "Sender: <$MAILFROM>" |
|
|
|
fi |
|
|
|
echo "To: $MAILTO" |
|
|
@ -131,4 +139,6 @@ fi |
|
|
|
|
|
|
|
if [ "yes" != "$SUBMITTED" ] ; then |
|
|
|
logger -t popularity-contest "unable to submit report." |
|
|
|
else |
|
|
|
mv $POPCON $POPCONOLD |
|
|
|
fi |
|
|
|