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.
  • Loading branch information
elseym authored and fpletz committed Oct 10, 2017
1 parent da93e6e commit aeeac71
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 aeeac71

Please sign in to comment.