Merge pull request #142803 from mkg20001/matomoplugins

This commit is contained in:
Maciej Krüger 2021-11-09 16:02:46 +01:00 committed by GitHub
commit f096b7122a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 11 deletions

View file

@ -24,6 +24,7 @@ in {
(mkRemovedOptionModule [ "services" "piwik" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
(mkRemovedOptionModule [ "services" "matomo" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
(mkRenamedOptionModule [ "services" "piwik" "nginx" ] [ "services" "matomo" "nginx" ])
(mkRenamedOptionModule [ "services" "matomo" "periodicArchiveProcessingUrl" ] [ "services" "matomo" "hostname" ])
];
options = {
@ -77,7 +78,7 @@ in {
'';
};
periodicArchiveProcessingUrl = mkOption {
hostname = mkOption {
type = types.str;
default = "${user}.${fqdn}";
example = "matomo.yourdomain.org";
@ -170,6 +171,19 @@ in {
fi
chown -R ${user}:${user} ${dataDir}
chmod -R ug+rwX,o-rwx ${dataDir}
if [ -e ${dataDir}/current-package ]; then
CURRENT_PACKAGE=$(readlink ${dataDir}/current-package)
NEW_PACKAGE=${cfg.package}
if [ "$CURRENT_PACKAGE" != "$NEW_PACKAGE" ]; then
# keeping tmp arround between upgrades seems to bork stuff, so delete it
rm -rf ${dataDir}/tmp
fi
elif [ -e ${dataDir}/tmp ]; then
# upgrade from 4.4.1
rm -rf ${dataDir}/tmp
fi
ln -sfT ${cfg.package} ${dataDir}/current-package
'';
script = ''
# Use User-Private Group scheme to protect Matomo data, but allow administration / backup via 'matomo' group
@ -202,7 +216,7 @@ in {
UMask = "0007";
CPUSchedulingPolicy = "idle";
IOSchedulingClass = "idle";
ExecStart = "${cfg.package}/bin/matomo-console core:archive --url=https://${cfg.periodicArchiveProcessingUrl}";
ExecStart = "${cfg.package}/bin/matomo-console core:archive --url=https://${cfg.hostname}";
};
};
@ -258,7 +272,7 @@ in {
# References:
# https://fralef.me/piwik-hardening-with-nginx-and-php-fpm.html
# https://github.com/perusio/piwik-nginx
"${user}.${fqdn}" = mkMerge [ cfg.nginx {
"${cfg.hostname}" = mkMerge [ cfg.nginx {
# don't allow to override the root easily, as it will almost certainly break Matomo.
# disadvantage: not shown as default in docs.
root = mkForce "${cfg.package}/share";

View file

@ -3,16 +3,16 @@
let
versions = {
matomo = {
version = "4.4.1";
sha256 = "0y8ljdj97znvd3hkkr7s6s9k8m93agw3z9cfw1azzaxgc46akfcl";
version = "4.5.0";
sha256 = "sha256-OyjdzY+ENYxOTVjDLjj2unJbpaGODIH2I5Acmt45HDA=";
};
matomo-beta = {
version = "4.4.1";
version = "4.6.0";
# `beta` examples: "b1", "rc1", null
# TOOD when updating: use null if stable version is >= latest beta or release candidate
beta = null;
sha256 = "0y8ljdj97znvd3hkkr7s6s9k8m93agw3z9cfw1azzaxgc46akfcl";
# when updating: use null if stable version is >= latest beta or release candidate
beta = "b2";
sha256 = "sha256-7p/ZPtr5a/tBjrM27ILF3rNfxDIWuzWKCXNom3HlyL8=";
};
};
common = pname: { version, sha256, beta ? null }:
@ -74,10 +74,9 @@ let
"misc/composer/clean-xhprof.sh"
"misc/cron/archive.sh"
"plugins/Installation/FormDatabaseSetup.php"
"vendor/leafo/lessphp/package.sh"
"vendor/pear/archive_tar/sync-php4"
"vendor/szymach/c-pchart/coverage.sh"
# drupal_test.sh does not exist in 3.12.0-b3; added for 3.13.0
"vendor/matomo/matomo-php-tracker/run_tests.sh"
"vendor/twig/twig/drupal_test.sh"
];
@ -92,6 +91,8 @@ let
length="$(wc -c "$f" | cut -d' ' -f1)"
hash="$(md5sum "$f" | cut -d' ' -f1)"
sed -i "s:\\(\"$f\"[^(]*(\\).*:\\1\"$length\", \"$hash\"),:g" config/manifest.inc.php
else
echo "INFO(files-to-fix): $f does not exist in this version"
fi
done
popd > /dev/null