fix db
This commit is contained in:
@@ -32,6 +32,7 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.postgresql.postStart = lib.mkAfter ''
|
systemd.services.postgresql.postStart = lib.mkAfter ''
|
||||||
|
${pkgs.coreutils}/bin/sleep 2
|
||||||
PSQL="${pkgs.postgresql}/bin/psql"
|
PSQL="${pkgs.postgresql}/bin/psql"
|
||||||
${lib.concatMapStringsSep "\n" (name: ''
|
${lib.concatMapStringsSep "\n" (name: ''
|
||||||
until $PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname = '${name}_user'" | grep -q 1; do
|
until $PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname = '${name}_user'" | grep -q 1; do
|
||||||
@@ -41,7 +42,7 @@ in {
|
|||||||
$PSQL -tAc "ALTER DATABASE ${name}_db OWNER TO ${name}_user;"
|
$PSQL -tAc "ALTER DATABASE ${name}_db OWNER TO ${name}_user;"
|
||||||
|
|
||||||
if [ -f "${config.sops.secrets."${lib.toUpper name}".path}" ]; then
|
if [ -f "${config.sops.secrets."${lib.toUpper name}".path}" ]; then
|
||||||
PASS=$(grep "^DB_PASSWORD=" ... | cut -d'=' -f2- | tr -d '"' | tr -d "'")
|
PASS=$(grep "^DB_PASSWORD=" "${config.sops.secrets."${lib.toUpper name}".path}" | cut -d'=' -f2- | tr -d '"' | tr -d "'")
|
||||||
$PSQL -tAc "ALTER USER ${name}_user WITH PASSWORD '$PASS';"
|
$PSQL -tAc "ALTER USER ${name}_user WITH PASSWORD '$PASS';"
|
||||||
fi
|
fi
|
||||||
'') allApps}
|
'') allApps}
|
||||||
|
|||||||
Reference in New Issue
Block a user