Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
refactor: superuser for start-server/client
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Sep 18, 2023
1 parent 10e99b1 commit 569fbb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
]; in flake-utils.lib.eachSystem ourSystems (system:
let
pgsqlDefaultPort = "5435";
pgsqlSuperuser = "postgres";

# The 'pkgs' variable holds all the upstream packages in nixpkgs, which
# we can use to build our own images; it is the common name to refer to
Expand Down Expand Up @@ -261,6 +262,7 @@
mkdir -p $out/bin
substitute ${./tools/run-server.sh.in} $out/bin/start-postgres-server \
--subst-var-by 'PGSQL_DEFAULT_PORT' '${pgsqlDefaultPort}' \
--subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \
--subst-var-by 'PSQL14_BINDIR' '${basePackages.psql_14.bin}' \
--subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \
--subst-var-by 'PSQL_CONF_FILE' '${configFile}' \
Expand All @@ -274,6 +276,7 @@
mkdir -p $out/bin
substitute ${./tools/run-client.sh.in} $out/bin/start-postgres-client \
--subst-var-by 'PGSQL_DEFAULT_PORT' '${pgsqlDefaultPort}' \
--subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \
--subst-var-by 'PSQL14_BINDIR' '${basePackages.psql_14.bin}' \
--subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}'
chmod +x $out/bin/start-postgres-client
Expand Down
3 changes: 2 additions & 1 deletion tools/run-client.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ fi
export PATH=$BINDIR/bin:$PATH

PORTNO="${2:-@PGSQL_DEFAULT_PORT@}"
PGSQL_SUPERUSER=@PGSQL_SUPERUSER@

exec psql -p "$PORTNO" -h localhost postgres
exec psql -U "$PGSQL_SUPERUSER" -p "$PORTNO" -h localhost postgres
3 changes: 2 additions & 1 deletion tools/run-server.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fi

export PATH=$BINDIR/bin:$PATH

PGSQL_SUPERUSER=@PGSQL_SUPERUSER@
PSQL_CONF_FILE=@PSQL_CONF_FILE@
PGSODIUM_GETKEY_SCRIPT=@PGSODIUM_GETKEY@
PORTNO="${2:-@PGSQL_DEFAULT_PORT@}"
Expand All @@ -30,7 +31,7 @@ echo "NOTE: using temporary directory $DATDIR for data, which will not be remove
echo "NOTE: you are free to re-use this data directory at will"
echo

initdb -D "$DATDIR" --locale=C
initdb -U "$PGSQL_SUPERUSER" -D "$DATDIR" --locale=C

echo "NOTE: patching postgresql.conf files"
sed \
Expand Down

0 comments on commit 569fbb4

Please sign in to comment.