summary refs log tree commit diff
path: root/nixos/modules/services/web-apps
diff options
context:
space:
mode:
authorelseym <elseym@me.com>2017-10-09 20:23:48 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-10-10 20:08:21 +0200
commitaeeac71231f5ca103eb484815130a864fc571d64 (patch)
treeb37d1cd31aecbe7230070d97ffa035b5bebfa534 /nixos/modules/services/web-apps
parentda93e6e6789dc52e24571179726813ca9d4eed61 (diff)
downloadnixlib-aeeac71231f5ca103eb484815130a864fc571d64.tar
nixlib-aeeac71231f5ca103eb484815130a864fc571d64.tar.gz
nixlib-aeeac71231f5ca103eb484815130a864fc571d64.tar.bz2
nixlib-aeeac71231f5ca103eb484815130a864fc571d64.tar.lz
nixlib-aeeac71231f5ca103eb484815130a864fc571d64.tar.xz
nixlib-aeeac71231f5ca103eb484815130a864fc571d64.tar.zst
nixlib-aeeac71231f5ca103eb484815130a864fc571d64.zip
mattermost: create role and db with postgres superuser
Recently, the postgres superuser name has changed. Using the configured
and correct username here fixes database initialisation.
Diffstat (limited to 'nixos/modules/services/web-apps')
-rw-r--r--nixos/modules/services/web-apps/mattermost.nix10
1 files changed, 6 insertions, 4 deletions
diff --git a/nixos/modules/services/web-apps/mattermost.nix b/nixos/modules/services/web-apps/mattermost.nix
index bc88a808abc9..0b637e3991b4 100644
--- a/nixos/modules/services/web-apps/mattermost.nix
+++ b/nixos/modules/services/web-apps/mattermost.nix
@@ -184,10 +184,12 @@ in
           fi
         '' + lib.optionalString cfg.localDatabaseCreate ''
           if ! test -e "${cfg.statePath}/.db-created"; then
-            ${config.services.postgresql.package}/bin/psql postgres -c \
-              "CREATE ROLE ${cfg.localDatabaseUser} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${cfg.localDatabasePassword}'"
-            ${config.services.postgresql.package}/bin/createdb \
-              --owner ${cfg.localDatabaseUser} ${cfg.localDatabaseName}
+            ${pkgs.sudo}/bin/sudo -u ${config.services.postgresql.superUser} \
+              ${config.services.postgresql.package}/bin/psql postgres -c \
+                "CREATE ROLE ${cfg.localDatabaseUser} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${cfg.localDatabasePassword}'"
+            ${pkgs.sudo}/bin/sudo -u ${config.services.postgresql.superUser} \
+              ${config.services.postgresql.package}/bin/createdb \
+                --owner ${cfg.localDatabaseUser} ${cfg.localDatabaseName}
             touch ${cfg.statePath}/.db-created
           fi
         '' + ''