nix: improve prymn_db script, adding a 'shell' command

This commit is contained in:
Nikos Papadakis 2023-12-14 14:45:22 +02:00
parent 818b20f775
commit 62c40358a2
Signed by untrusted user who does not match committer: nikos
GPG key ID: 78871F9905ADFF02

View file

@ -15,6 +15,7 @@
export PGHOST=/tmp export PGHOST=/tmp
export DB_LOG=$PROJECT_ROOT_DIR/.db/log export DB_LOG=$PROJECT_ROOT_DIR/.db/log
start_db() {
if [ ! -d "$PGDATA" ]; then if [ ! -d "$PGDATA" ]; then
initdb "$PGDATA" --auth=trust initdb "$PGDATA" --auth=trust
fi fi
@ -28,6 +29,19 @@
if [ "$user_exists" != "1" ]; then if [ "$user_exists" != "1" ]; then
createuser -s -h "$PGHOST" postgres createuser -s -h "$PGHOST" postgres
fi fi
}
command="''${1-default}"
case $command in
shell)
psql -U postgres
exit 0
;;
start | default | *)
start_db
exit 0
;;
esac
''; '';
}; };
} }