Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Last active April 25, 2018 03:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save szepeviktor/59931721b26fc750cf18 to your computer and use it in GitHub Desktop.
Save szepeviktor/59931721b26fc750cf18 to your computer and use it in GitHub Desktop.
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