Matomo-Updater
Ich habe bei meinem Hoster ein shared Hosting. Dort läuft seit (gefühlt) “ewig” eine Piwik-Instanz. Heute Matomo.
Das aktuellste Matomo Zipfile enthält das Unterverzeichnis “matomo”. Aber meine Instanz liegt noch in einem andersnamigen Verzeichnis.
Damit ich auch künftig weiter automatisiert auf die aktuelle Matomo Version aktualisieren kann, habe ich ein Shellskript geschrieben, was das entpackte Achiv ins eigentliche Installverzeichnis schiebt.
Falls dies noch wer gebrauchen kann … bitteschön und am liebsten auf Github schauen [2] :-) Anzupassen ist der Bereich Config…
#!/bin/bash
# ======================================================================
#
# MATOMO UPDATER
#
# ----------------------------------------------------------------------
# Download latest matomo and install into any directory
# (even if not named matomo, i.e. piwik)
# ----------------------------------------------------------------------
#
# requires these binaries in the path
# - wget
# - unzip
# - rsync
# - php
#
# ----------------------------------------------------------------------
# 2018-10-18 v1.0 www.axel-hahn.de
# ======================================================================
# ----------------------------------------------------------------------
# CONFIG
# ----------------------------------------------------------------------
# webroot ... you can leave it empty if you have a shared hosting
# sWebroot='/var/www/html'
sWebroot=''
# subdir of your matomo installation - as relative dir below webroot
appDir="piwik"
sDownloadUrl='https://builds.matomo.org/matomo.zip'
xDir="tmp-matomo"
xDir2="${xDir}/matomo"
Zipfile="${xDir}/matomo.zip"
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
echo
echo ========== MATOMO UPDATER ==========
echo
echo --- cd to webroot [${sWebroot}]
cd ${sWebroot} || exit 1
pwd
echo
echo --- small check if MATOMO is in [${appDir}] ...
ls -l ${appDir}/console ${appDir}/config/config.ini.php || exit 2
echo OK.
echo
echo --- create temp dir [${xDir}]
mkdir "${xDir}" || exit 3
echo OK.
echo
echo --- download to [${Zipfile}]
wget -O ${Zipfile} ${sDownloadUrl} || exit 3
echo OK.
echo
echo --- extract [${Zipfile}] in temp directory [${xDir}] ...
unzip -uoq ${Zipfile} -d "${xDir}" || exit 4
ls -ld ${xDir2} || exit 5
echo OK.
echo
echo --- saving current config
sBakfile=${appDir}/config/config.ini.`date +%Y%m%d_%H%M%S`.php
cp ${appDir}/config/config.ini.php ${sBakfile} || exit 6
ls -l ${sBakfile}
echo OK.
echo
echo --- sync new files form [${xDir2}] to current install dir [${appDir}]
rsync -r ${xDir2}/* ${appDir} || exit 7
echo OK.
echo
echo --- update database
php ${appDir}/console core:update || exit 8
echo OK, UPDATE SUCCESSFUL.
echo
echo --- finally: cleanup all temp data in [${xDir}] ...
rm -rf ${xDir} || exit 9
echo OK.
echo
echo DONE.
# ----------------------------------------------------------------------
Updates:
- 22.11.2018: Github-Repository hinzugefügt
weiterführende Links:
Kommentar hinzufügen
Die Felder Name und Kommentar sind Pflichtfelder.