Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion nixos/modules/services/web-apps/matomo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ in {
chmod -R u+rwX,g+rwX,o-rwx "${dataDir}"

# check whether user setup has already been done
if test -f "${dataDir}/config/config.ini.php"; then
if test -f "${dataDir}/config/config.ini.php" &&
# since matomo-5.2.0, the config.ini.php is already created at first
# installer page access https://github.com/matomo-org/matomo/issues/22932
grep -q -F "[database]" "${dataDir}/config/config.ini.php"; then
# then execute possibly pending database upgrade
matomo-console core:update --yes
fi
Expand Down
14 changes: 14 additions & 0 deletions nixos/tests/matomo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,25 @@ let
machine.wait_for_unit("phpfpm-matomo.service")
machine.wait_for_unit("nginx.service")

with subtest("matomo.js reachable via HTTP"):
machine.succeed("curl -sSfk http://machine/matomo.js")

with subtest("js/piwik.js reachable via HTTP"):
machine.succeed("curl -sSfk http://machine/js/piwik.js")

with subtest("matomo.php (API) reachable via HTTP"):
machine.succeed("curl -sSfk http://machine/matomo.php")

# without the grep the command does not produce valid utf-8 for some reason
with subtest("welcome screen loads"):
machine.succeed(
"curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'"
)

with subtest("killing the phpfpm process should trigger an automatic restart"):
machine.succeed("systemctl kill -s KILL phpfpm-matomo")
machine.sleep(1)
machine.wait_for_unit("phpfpm-matomo.service")
'';
};
in
Expand Down