Skip to content

Commit

Permalink
mattermost: create role and db with postgres superuser
Browse files Browse the repository at this point in the history
Recently, the postgres superuser name has changed. Using the configured
and correct username here fixes database initialisation.

(cherry picked from commit aeeac71)
  • Loading branch information
elseym authored and fpletz committed Jan 8, 2018
1 parent d7bd2fc commit 5431160
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nixos/modules/services/web-apps/mattermost.nix
Expand Up @@ -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
'' + ''
Expand Down

0 comments on commit 5431160

Please sign in to comment.