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.
This commit is contained in:
elseym 2017-10-09 20:23:48 +02:00 committed by Franz Pletz
parent da93e6e678
commit aeeac71231

View File

@ -184,10 +184,12 @@ in
fi fi
'' + lib.optionalString cfg.localDatabaseCreate '' '' + lib.optionalString cfg.localDatabaseCreate ''
if ! test -e "${cfg.statePath}/.db-created"; then if ! test -e "${cfg.statePath}/.db-created"; then
${config.services.postgresql.package}/bin/psql postgres -c \ ${pkgs.sudo}/bin/sudo -u ${config.services.postgresql.superUser} \
"CREATE ROLE ${cfg.localDatabaseUser} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${cfg.localDatabasePassword}'" ${config.services.postgresql.package}/bin/psql postgres -c \
${config.services.postgresql.package}/bin/createdb \ "CREATE ROLE ${cfg.localDatabaseUser} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${cfg.localDatabasePassword}'"
--owner ${cfg.localDatabaseUser} ${cfg.localDatabaseName} ${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 touch ${cfg.statePath}/.db-created
fi fi
'' + '' '' + ''