Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Last active April 25, 2018 03:56
Embed
What would you like to do?
Piwik automatic update - bash script
#!/bin/bash
# Start this scipt above the /piwik directory.
# We assume that the webserver runs under www-data.
# download & verify
wget -nv "http://builds.piwik.org/piwik.zip" || exit 1
wget -nv "http://builds.piwik.org/piwik.zip.asc" || exit 2
gpg --verify piwik.zip.asc || exit 3
# update files in piwik/ directory
unzip -o piwik.zip "piwik/*" | sed 's/.*/./' | paste -s -d'.'
# show version
echo -n "New PIWIK Version: "
grep 'const VERSION' piwik/core/Version.php|cut -d"'" -f2 || echo "ERROR: Failed to detect version" >&2
# DB update
# double it to make sure
piwik/console core:update --no-interaction
piwik/console core:update --no-interaction
# clean up
# no need to `rm`, see: "How to install Piwik.html"
rm -v piwik.zip piwik.zip.asc
chown -R www-data:www-data . || echo "ERROR: Failed to set permissions." >&2
# purge opcache
# see: https://github.com/gordalina/cachetool
echo -n "Purge cache status: "
cachetool opcache:reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment