#!/bin/sh -e _su(){ su-exec postgres "$@" } if ! [ -s "$PGDATA"/PG_VERSION ]; then echo "Initializing database" _su initdb --username=postgres _su pg_ctl -D "$PGDATA" \ -o "-c listen_addresses=''" \ -w start # create database for gitlab _su psql -c "CREATE USER git CREATEDB;" _su psql -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" _su psql -c "CREATE DATABASE gitlabhq_production OWNER git;" _su pg_ctl -D "$PGDATA" -m fast -w stop fi _su "$@"