fix script
This commit is contained in:
51
lib.nix
51
lib.nix
@@ -111,32 +111,33 @@ in
|
|||||||
setupScript = pkgs.writeShellApplication {
|
setupScript = pkgs.writeShellApplication {
|
||||||
name = "setup-postgres";
|
name = "setup-postgres";
|
||||||
text = ''
|
text = ''
|
||||||
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 "$PGDATA" ]]; then
|
if [[ ! -d "$PGDATA" ]]; then
|
||||||
initdb --no-instructions
|
initdb --no-instructions
|
||||||
POSTGRES_RUN_INITIAL_SCRIPT="true"
|
POSTGRES_RUN_INITIAL_SCRIPT="true"
|
||||||
echo
|
echo
|
||||||
echo "PostgreSQL initdb process completed"
|
echo "PostgreSQL initdb process completed"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
substituteAllInPlace $PGDATA/postgresql.conf
|
substituteAllInPlace $PGDATA/postgresql.conf
|
||||||
cp ${configFile} $PGDATA/postgresql.conf
|
cp ${configFile} $PGDATA/postgresql.conf
|
||||||
if [[ "$POSTGRES_RUN_INITIAL_SCRIPT" == "true" ]]; then
|
if [[ "$POSTGRES_RUN_INITIAL_SCRIPT" == "true" ]]; then
|
||||||
echo
|
echo
|
||||||
echo "PostgreSQL is setting up the initial database"
|
echo "PostgreSQL is setting up the initial database"
|
||||||
echo
|
echo
|
||||||
pg_ctl -w start -o "-c unix_socket_directories=$PGHOST -c listen_addresses= -p ${builtins.toString port}"
|
pg_ctl -w start -o "-c unix_socket_directories=$PGHOST -c listen_addresses= -p ${builtins.toString port}"
|
||||||
pg_ctl -m fast -w stop
|
pg_ctl -m fast -w stop
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "Database directory exists. Skipping initialization"
|
echo "Database directory exists. Skipping initialization"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset POSTGRES_RUN_INITIAL_SCRIPT
|
unset POSTGRES_RUN_INITIAL_SCRIPT
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
script = pkgs.writeShellApplication {
|
script = pkgs.writeShellApplication {
|
||||||
name = "run-postgres";
|
name = "run-postgres";
|
||||||
|
|||||||
Reference in New Issue
Block a user