From dd527d596850574b83f7d9f4903e3191a35ed7af Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Wed, 6 May 2020 11:28:09 +0300 Subject: [PATCH] Ensure correct dimension.db file ownership This is mostly here to guard against problems happening due to server migration and doing `chown -R matrix:matrix /matrix`. Normally, the file is owned by `1000:1000`, as expected. If ownership changes, Dimension could still start, but it will fail the first time it tries to write to the database. Explicitly chowning before startup guards against this. Related to #485 and #486 (Github Pull Requests). Also related to ccc7aaf0ce47262beb. --- .../templates/systemd/matrix-dimension.service.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/matrix-dimension/templates/systemd/matrix-dimension.service.j2 b/roles/matrix-dimension/templates/systemd/matrix-dimension.service.j2 index c32027b12..0a8d0c839 100644 --- a/roles/matrix-dimension/templates/systemd/matrix-dimension.service.j2 +++ b/roles/matrix-dimension/templates/systemd/matrix-dimension.service.j2 @@ -9,6 +9,9 @@ Type=simple ExecStartPre=-/usr/bin/docker kill matrix-dimension ExecStartPre=-/usr/bin/docker rm matrix-dimension +# Fixup database ownership if it got changed somehow (during a server migration, etc.) +ExecStartPre=-/usr/bin/chown {{ matrix_dimension_user_uid }}:{{ matrix_dimension_user_gid }} {{ matrix_dimension_base_path }}/dimension.db + ExecStart=/usr/bin/docker run --rm --name matrix-dimension \ --log-driver=none \ --user={{ matrix_dimension_user_uid }}:{{ matrix_dimension_user_gid }} \