#!/usr/bin/env sh set -e if [ -n "$POSTGRES_APP_USER" ]; then psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER:-postgres}" --dbname "$" <<-EOSQL CREATE USER $POSTGRES_APP_USER with encrypted password '$POSTGRES_APP_PASSWORD'; GRANT CREATE, CONNECT ON DATABASE ${POSTGRES_DB:-postgres} TO $POSTGRES_APP_USER; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, UPDATE, INSERT, DELETE, REFERENCES ON TABLES TO $POSTGRES_APP_USER; EOSQL fi