Configure Matomo offline logs

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2019-10-24 13:00:49 +02:00
parent bada941362
commit 374d678c9b
2 changed files with 25 additions and 1 deletions

View file

@ -8,6 +8,8 @@ echo "Sentry DNS:"
read sentry
echo "Matomo site id:"
read matomo
echo "Matomo token:"
read matomo_token
echo "Munin allow:"
read munin

@ -17,9 +19,12 @@ cat > /etc/weblate-bootstrap <<EOT
WEBLATE_DOMAIN="$domain"
WEBLATE_TITLE="$title"
WEBLATE_SECRET=$(openssl rand -hex 32)
WEBLATE_PIWIK="$matomo"
WEBLATE_SENTRY="$sentry"

# Matomo
MATOMO_SITE="$matomo"
MATOMO_TOKEN="$matomo_token"

# Exim
EXIM_PASS=$smtp_pass
# $(openssl passwd -6 "$smtp_pass")

View file

@ -134,3 +134,22 @@ EOT
sed -i "0,/server_name $WEBLATE_DOMAIN.*/s//&\\ninclude snippets\/weblate.conf;/" /etc/nginx/sites-available/default
# Delete default location, replaced by snippet
sed -i ':a;N;$!ba;s/\(snippets\/weblate.conf;\)[^}]*}/\1/g' /etc/nginx/sites-available/default

# Matomo
sudo -u weblate git clone https://github.com/matomo-org/matomo-log-analytics.git /home/weblate/matomo-log-analytics
cat > /home/weblate/run-matomo.sh <<EOT
#!/bin/sh
/usr/bin/python2 \
/home/weblate/matomo-log-analytics/import_logs.py \
--url=https://stats.cihar.com/ \
--idsite=$MATOMO_SITE \
--token-auth=$MATOMO_TOKEN \
/var/log/nginx/access.log.1
EOT
chmod +x /home/weblate/run-matomo.sh
chown weblate:weblate /home/weblate/run-matomo.sh
crontab -u weblate -l > /tmp/weblate-cron
echo >> /tmp/weblate-cron
echo '0 7 * * * /home/weblate/run-matomo.sh' >> /tmp/weblate-cron
crontab -u weblate /tmp/weblate-cron
rm /tmp/weblate-cron