fix script

This commit is contained in:
2025-03-17 13:27:31 +04:00
parent 19350df1d5
commit dbfcda72d8

51
lib.nix
View File

@@ -111,32 +111,33 @@ in
setupScript = pkgs.writeShellApplication {
name = "setup-postgres";
text = ''
set -euo pipefail
export PATH=${package}/bin:${pkgs.coreutils}/bin
POSTGRES_RUN_INITIAL_SCRIPT="false"
if [[ ! -d "$PGDATA" ]]; then
initdb --no-instructions
POSTGRES_RUN_INITIAL_SCRIPT="true"
echo
echo "PostgreSQL initdb process completed"
echo
fi
substituteAllInPlace $PGDATA/postgresql.conf
cp ${configFile} $PGDATA/postgresql.conf
if [[ "$POSTGRES_RUN_INITIAL_SCRIPT" == "true" ]]; then
echo
echo "PostgreSQL is setting up the initial database"
echo
pg_ctl -w start -o "-c unix_socket_directories=$PGHOST -c listen_addresses= -p ${builtins.toString port}"
pg_ctl -m fast -w stop
else
echo
echo "Database directory exists. Skipping initialization"
echo
fi
set -euo pipefail
export PATH=${package}/bin:${pkgs.coreutils}/bin
POSTGRES_RUN_INITIAL_SCRIPT="false"
if [[ ! -d "$PGDATA" ]]; then
initdb --no-instructions
POSTGRES_RUN_INITIAL_SCRIPT="true"
echo
echo "PostgreSQL initdb process completed"
echo
fi
substituteAllInPlace $PGDATA/postgresql.conf
cp ${configFile} $PGDATA/postgresql.conf
if [[ "$POSTGRES_RUN_INITIAL_SCRIPT" == "true" ]]; then
echo
echo "PostgreSQL is setting up the initial database"
echo
pg_ctl -w start -o "-c unix_socket_directories=$PGHOST -c listen_addresses= -p ${builtins.toString port}"
pg_ctl -m fast -w stop
else
echo
echo "Database directory exists. Skipping initialization"
echo
fi
unset POSTGRES_RUN_INITIAL_SCRIPT
'';
unset POSTGRES_RUN_INITIAL_SCRIPT
'';
};
script = pkgs.writeShellApplication {
name = "run-postgres";