Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -xeEuo pipefail
- echo "starting up postgres docker image:"
- echo "$@"
- # check PGDATA directory and create if necessary
- if [ \! -d $PGDATA ] || [ \! -O $PGDATA ]
- then
- mkdir -p $PGDATA
- chmod 700 $PGDATA
- fi
- # check database cluster in PGDATA directory and create new db cluster if necessary
- if [ \! -s $PGDATA/PG_VERSION ] || ! pg_controldata
- then
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-"Start1234"}
- initdb -D $PGDATA --locale=de_DE.UTF-8 --lc-messages=en_US.UTF-8 --auth-local=trust --auth-host=md5 --pwfile=<(echo "$POSTGRES_PASSWORD")
- mv $PGDATA/postgresql.conf $PGDATA/postgresql.conf.orig
- cp ~/postgresql.conf.${PG_MAJOR} $PGDATA/postgresql.conf
- mkdir -p $PGDATA/conf.d
- cp ~/00-ina-default.conf $PGDATA/conf.d/
- {
- echo "# allow connections via docker gateway or bridge"
- echo "host all all 172.16.0.0/14 md5"
- } >> "$PGDATA/pg_hba.conf"
- fi
- # show PGDATA version and controldata
- echo "PGDATA/PGVERSION=`cat $PGDATA/PG_VERSION`"
- # start postgres rdbms now
- exec "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement