fix script
This commit is contained in:
20
lib.nix
20
lib.nix
@@ -115,9 +115,8 @@ in
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export PATH=${package}/bin:${pkgs.coreutils}/bin
|
export PATH=${package}/bin:${pkgs.coreutils}/bin
|
||||||
POSTGRES_RUN_INITIAL_SCRIPT="false"
|
POSTGRES_RUN_INITIAL_SCRIPT="false"
|
||||||
if [[ ! -d "${data_dir}" ]]; then
|
if [[ ! -d "$PGDATA" ]]; then
|
||||||
|
initdb --no-instructions
|
||||||
initdb -D ${data_dir} --no-instructions
|
|
||||||
POSTGRES_RUN_INITIAL_SCRIPT="true"
|
POSTGRES_RUN_INITIAL_SCRIPT="true"
|
||||||
echo
|
echo
|
||||||
echo "PostgreSQL initdb process completed"
|
echo "PostgreSQL initdb process completed"
|
||||||
@@ -128,16 +127,8 @@ in
|
|||||||
echo
|
echo
|
||||||
echo "PostgreSQL is setting up the initial database"
|
echo "PostgreSQL is setting up the initial database"
|
||||||
echo
|
echo
|
||||||
if [[ -z "''${PGHOST+x}" ]]; then
|
pg_ctl -w start -o "-c unix_socket_directories=${data_dir} -c listen_addresses= -p ${builtins.toString port}"
|
||||||
OLDPGHOST=""
|
pg_ctl -m fast -w stop
|
||||||
else
|
|
||||||
OLDPGHOST="$PGHOST"
|
|
||||||
fi
|
|
||||||
PGHOST=${lib.escapeShellArg runtimeDir}
|
|
||||||
pg_ctl -D "${data_dir}" -w start -o "-c unix_socket_directories=${data_dir} -c listen_addresses= -p ${builtins.toString port}"
|
|
||||||
pg_ctl -D "${data_dir}" -m fast -w stop
|
|
||||||
PGHOST="$OLDPGHOST"
|
|
||||||
unset OLDPGHOST
|
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "Database directory exists. Skipping initialization"
|
echo "Database directory exists. Skipping initialization"
|
||||||
@@ -151,9 +142,10 @@ in
|
|||||||
name = "run-postgres";
|
name = "run-postgres";
|
||||||
text = ''
|
text = ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
export PGDATA=${data_dir} PGHOST=${runtimeDir} PGPORT=${builtins.toString port}
|
||||||
mkdir -p ${lib.escapeShellArg runtimeDir}
|
mkdir -p ${lib.escapeShellArg runtimeDir}
|
||||||
${setupScript}/bin/setup-postgres
|
${setupScript}/bin/setup-postgres
|
||||||
exec ${package}/bin/postgres -D${data_dir}
|
exec ${package}/bin/postgres
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user