2018-12-18 02:08:53 +01:00
|
|
|
#!/usr/bin/env bash
|
2018-05-16 01:04:50 +02:00
|
|
|
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;
|
2018-05-23 04:07:16 +02:00
|
|
|
CREATE EXTENSION pgroonga;
|
|
|
|
GRANT USAGE ON SCHEMA pgroonga TO zulip;
|
2018-05-16 01:04:50 +02:00
|
|
|
"
|
|
|
|
|
|
|
|
if [ -f /.dockerenv ]; then
|
2019-04-02 01:00:57 +02:00
|
|
|
echo "$DATABASE_CREATE" | psql -v ON_ERROR_STOP=1 -e
|
2018-05-16 01:04:50 +02:00
|
|
|
else
|
2019-04-02 01:00:57 +02:00
|
|
|
echo "$DATABASE_CREATE" | su postgres -c 'psql -v ON_ERROR_STOP=1 -e'
|
2018-05-16 01:04:50 +02:00
|
|
|
fi
|