Files
zulip/scripts/setup/postgres-create-db
Anders Kaseorg 392175d6e8 Use #!/usr/bin/env for bash shebangs.
/bin/sh and /usr/bin/env are the only two binaries that NixOS provides
at a fixed path (outside a buildFHSUserEnv sandbox).

This discussion was split from #11004.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2018-12-17 17:21:08 -08:00

24 lines
512 B
Bash
Executable File

#!/usr/bin/env bash
set -e
set -x
# Make sure the current working directory is readable
cd /
DATABASE_CREATE="
CREATE USER zulip;
ALTER ROLE zulip SET search_path TO zulip,public;
CREATE DATABASE zulip OWNER=zulip;
\\connect zulip
CREATE SCHEMA zulip AUTHORIZATION zulip;
CREATE EXTENSION tsearch_extras SCHEMA zulip;
CREATE EXTENSION pgroonga;
GRANT USAGE ON SCHEMA pgroonga TO zulip;
"
if [ -f /.dockerenv ]; then
echo "$DATABASE_CREATE" | psql
else
echo "$DATABASE_CREATE" | su postgres -c psql
fi