Matomo Update Using Linux CLI

If you are hosting a Matomo Web Analytics installation on your Linux server, than you may find it useful to automate the update using a bash script. While Matomo is capable of doing a web based update, we strongly believe in the principle of least privilege. Using this principle ensures tight security, however this comes at the expense of flexibility in terms of updates. Without further ado, below is our bash update script to update Matomo from the command line.

#!/bin/bash
#
# Update matomo statistics data.
#
#
cd /var/www
cp -r matomo matomo.bkp
wget https://builds.matomo.org/matomo.zip
unzip -o matomo.zip
cd matomo
rm *.md LEGALNOTICE LICENSE
sed -i '/"LEGALNOTICE"/d' config/manifest.inc.php
sed -i '/"LICENSE"/d' config/manifest.inc.php
sed -i '/"CHANGELOG.md"/d' config/manifest.inc.php
sed -i '/"CONTRIBUTING.md"/d' config/manifest.inc.php
sed -i '/"README.md"/d' config/manifest.inc.php
sed -i '/"SECURITY.md"/d' config/manifest.inc.php
sed -i '/"PRIVACY.md"/d' config/manifest.inc.php
sed -i '/"LEGALNOTICE"/d' config/manifest.inc.php
chown -R root:root /var/www/matomo
chown -R www-data:root /var/www/matomo/tmp
chown -R www-data:root /var/www/matomo/matomo.js
chmod -R 0644 /var/www/matomo
find /var/www/matomo/ -type d -exec chmod 755 {} \;
php console core:update --yes
cd .. ; rm -r matomo.zip "How to install Matomo.html"

Stay tuned for our upcoming article WordPress Update Using Linux CLI.

Did you find this article useful? Why not share it with your friends?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.