some changes
This commit is contained in:
parent
0fd77fa375
commit
1e560576c0
1 changed files with 7 additions and 2 deletions
|
|
@ -124,6 +124,11 @@
|
|||
};
|
||||
users.groups."zoeyscomputer-phx" = {};
|
||||
|
||||
# Configure PostgreSQL authentication for our user
|
||||
services.postgresql.authentication = mkBefore ''
|
||||
local ${cfg.phx.database.name} ${cfg.phx.database.user} scram-sha-256
|
||||
'';
|
||||
|
||||
# Create a oneshot service to set up the database user with password
|
||||
systemd.services.init-zoeyscomputer-db = {
|
||||
description = "Initialize ZoeysComputer Database User";
|
||||
|
|
@ -143,10 +148,10 @@
|
|||
|
||||
# Create user and database if they don't exist
|
||||
if ! runuser -u ${config.services.postgresql.superUser} -- ${config.services.postgresql.package}/bin/psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='${cfg.phx.database.user}'" | grep -q 1; then
|
||||
echo "CREATE USER ${cfg.phx.database.user} WITH PASSWORD '$PASSWORD'" | \
|
||||
echo "CREATE USER ${cfg.phx.database.user} WITH PASSWORD '$PASSWORD' PASSWORD_ENCRYPTION='scram-sha-256'" | \
|
||||
runuser -u ${config.services.postgresql.superUser} -- ${config.services.postgresql.package}/bin/psql
|
||||
else
|
||||
echo "ALTER USER ${cfg.phx.database.user} WITH PASSWORD '$PASSWORD'" | \
|
||||
echo "ALTER USER ${cfg.phx.database.user} WITH PASSWORD '$PASSWORD' PASSWORD_ENCRYPTION='scram-sha-256'" | \
|
||||
runuser -u ${config.services.postgresql.superUser} -- ${config.services.postgresql.package}/bin/psql
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue