fix script
This commit is contained in:
55
lib.nix
55
lib.nix
@@ -108,37 +108,32 @@ in
|
||||
)
|
||||
);
|
||||
};
|
||||
setupScript = pkgs.writeShellApplication {
|
||||
runtimeInputs = [ pkgs.makeWrapper ];
|
||||
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
|
||||
setupScript = pkgs.writeShellScriptBin "setup-postgres" ''
|
||||
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
|
||||
sed "s|@PGHOST|''${PGHOST}|g" ${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";
|
||||
|
||||
Reference in New Issue
Block a user