beagle: matrix: configure clan states
This commit is contained in:
parent
4572f58328
commit
877bf6e204
1 changed files with 67 additions and 28 deletions
|
|
@ -1,40 +1,79 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
services.postgresql =
|
clan.core.postgresql = {
|
||||||
let
|
enable = true;
|
||||||
databases = [
|
|
||||||
"matrix-synapse"
|
|
||||||
"mautrix-signal"
|
|
||||||
"mautrix-whatsapp"
|
|
||||||
"mautrix-telegram"
|
|
||||||
];
|
|
||||||
in
|
|
||||||
{
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
ensureDatabases = databases;
|
|
||||||
# Create a user for each database
|
|
||||||
ensureUsers = map (id: {
|
|
||||||
name = id;
|
|
||||||
ensureDBOwnership = true;
|
|
||||||
}) databases;
|
|
||||||
|
|
||||||
initialScript = pkgs.writeText "backend-initScript" ''
|
|
||||||
CREATE ROLE "matrix-synapse" WITH LOGIN;
|
|
||||||
CREATE DATABASE "matrix-synapse"
|
|
||||||
WITH ENCODING = 'UTF8'
|
|
||||||
TEMPLATE = template0
|
|
||||||
OWNER = "matrix-synapse"
|
|
||||||
LC_COLLATE = 'C'
|
|
||||||
LC_CTYPE = 'C';
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
users = {
|
||||||
|
matrix-synapse = { };
|
||||||
|
mautrix-signal = { };
|
||||||
|
mautrix-whatsapp = { };
|
||||||
|
mautrix-telegram = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
databases = {
|
||||||
|
matrix-synapse = {
|
||||||
|
create.options = {
|
||||||
|
ENCODING = "UTF8";
|
||||||
|
TEMPLATE = "template0";
|
||||||
|
OWNER = "matrix-synapse";
|
||||||
|
LC_COLLATE = "C";
|
||||||
|
LC_CTYPE = "C";
|
||||||
|
};
|
||||||
|
restore.stopOnRestore = [ "matrix-synapse" ];
|
||||||
|
};
|
||||||
|
mautrix-signal = {
|
||||||
|
restore.stopOnRestore = [ "mautrix-signal" ];
|
||||||
|
};
|
||||||
|
mautrix-whatsapp = {
|
||||||
|
restore.stopOnRestore = [ "mautrix-whatsapp" ];
|
||||||
|
};
|
||||||
|
mautrix-telegram = {
|
||||||
|
restore.stopOnRestore = [ "mautrix-telegram" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
clan.core.state.matrix = {
|
||||||
|
folders = [ "/var/backup/matrix-synapse" ];
|
||||||
|
|
||||||
|
preBackupScript = ''
|
||||||
|
export PATH=${
|
||||||
|
lib.makeBinPath [
|
||||||
|
pkgs.coreutils
|
||||||
|
pkgs.rsync
|
||||||
|
]
|
||||||
|
}
|
||||||
|
mkdir -p /var/backup/matrix-synapse
|
||||||
|
|
||||||
|
rsync -avH --delete --numeric-ids --include='homeserver.signing.key' --include='media_store' --exclude='media_store/remote_*' --exclude='media_store/url_cache*' /var/lib/matrix-synapse /var/backup/matrix-synapse/
|
||||||
|
'';
|
||||||
|
|
||||||
|
postRestoreScript = ''
|
||||||
|
export PATH=${
|
||||||
|
lib.makeBinPath [
|
||||||
|
config.systemd.package
|
||||||
|
pkgs.coreutils
|
||||||
|
pkgs.rsync
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
service_status="$(systemctl is-active matrix-synapse)"
|
||||||
|
|
||||||
|
systemctl stop matrix-synapse
|
||||||
|
|
||||||
|
rsync -avH --delete --numeric-ids /var/backup/matrix-synapse/ /var/lib/matrix-synapse/
|
||||||
|
|
||||||
|
if [ "$service_status" = "active" ]; then
|
||||||
|
systemctl start matrix-synapse
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
services.matrix-synapse = {
|
services.matrix-synapse = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue