Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authormatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-03-19 07:46:56 +0300
committermatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2009-03-19 07:46:56 +0300
commite247e19aee27eb437c94905342c13f3d67361ae6 (patch)
tree2d597f2218c11307cecee6f2ea04ad1a275bb966 /misc
parentf133ab8344d68e6dd590501d29304c811be1bfab (diff)
- fixes #599 Make archive.sh not accessible via http; patch by pebosi and vipsoft!
Diffstat (limited to 'misc')
-rw-r--r--misc/cron/archive.sh32
1 files changed, 24 insertions, 8 deletions
diff --git a/misc/cron/archive.sh b/misc/cron/archive.sh
index 4a41d7d8e9..585c3c8f23 100644
--- a/misc/cron/archive.sh
+++ b/misc/cron/archive.sh
@@ -1,19 +1,35 @@
#!/bin/bash -e
-# HOW TO SETUP THE CRONTAB JOB
+# Description
+# This script automatically fetches the Super User token_auth
+# and triggers the archiving for all websites for all periods.
+# This ensures that all reports are pre-computed and Piwik renders very fast.
+
+# Documentation
+# Please check the documentation on http://piwik.org/docs/setup-auto-archiving/
+
+# How to setup the crontab job?
# Add the following lines in your crontab file, eg. /etc/cron.d/piwik-archive
#MAILTO="youremail@example.com"
#5 0 * * * www-data /path/to/piwik/misc/cron/archive.sh > /dev/null
-# OPTIMIZATION FOR HIGH TRAFFIC WEBSITE
-# Please change the following settings in config/global.ini.php
-# time_before_archive_considered_outdated = 3600
-# enable_browser_archiving_triggering = false
+# Other optimization for high traffic websites
+# You may want to override the following settings in config/config.ini.php (see documentation in config/config.ini.php)
+# [General]
+# time_before_archive_considered_outdated = 3600
+# enable_browser_archiving_triggering = false
+
+PHP_BIN=`which php5`
+PIWIK_CRON_FOLDER=`dirname $(readlink -f ${0})`
+PIWIK_PATH="$PIWIK_CRON_FOLDER"/../../index.php
+PIWIK_CONFIG="$PIWIK_CRON_FOLDER"/../../config/config.ini.php
-TOKEN_AUTH="" #you can get the token_auth from the Piwik admin UI (section Users, or section API)
+PIWIK_SUPERUSER=`sed '/^\[superuser\]/,$!d;/^login[ \t]*=[ \t]*"*/!d;s///;s/"*[ \t]*$//;q' $PIWIK_CONFIG`
+PIWIK_SUPERUSER_MD5_PASSWORD=`sed '/^\[superuser\]/,$!d;/^password[ \t]*=[ \t]*"*/!d;s///;s/"*[ \t]*$//;q' $PIWIK_CONFIG`
-PHP_BIN=/usr/bin/php5
-PIWIK_PATH=/home/www/piwik/demo/index.php
+CMD_TOKEN_AUTH="$PHP_BIN $PIWIK_PATH -- module=API&method=UsersManager.getTokenAuth&userLogin=$PIWIK_SUPERUSER&md5Password=$PIWIK_SUPERUSER_MD5_PASSWORD&format=php"
+CMD_TOKEN_AUTH_RESULT=`$CMD_TOKEN_AUTH`
+TOKEN_AUTH=${CMD_TOKEN_AUTH_RESULT:6:32}
for period in day week year; do
CMD="$PHP_BIN $PIWIK_PATH -- module=API&method=VisitsSummary.getVisits&idSite=all&period=$period&date=last52&format=xml&token_auth=$TOKEN_AUTH";