Advertisement
dulhaver

docker-entrypoint.sh

Jan 31st, 2022
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. #!/bin/bash
  2. set -xeEuo pipefail
  3.  
  4. echo "starting up postgres docker image:"
  5. echo "$@"
  6.  
  7. # check PGDATA directory and create if necessary
  8. if [ \! -d $PGDATA ] || [ \! -O $PGDATA ]
  9. then
  10.     mkdir -p $PGDATA
  11.     chmod 700 $PGDATA
  12. fi
  13.  
  14. # check database cluster in PGDATA directory and create new db cluster if necessary
  15. if [ \! -s $PGDATA/PG_VERSION ] || ! pg_controldata
  16. then
  17.     POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-"Start1234"}
  18.     initdb -D $PGDATA --locale=de_DE.UTF-8 --lc-messages=en_US.UTF-8 --auth-local=trust --auth-host=md5 --pwfile=<(echo "$POSTGRES_PASSWORD")
  19.     mv $PGDATA/postgresql.conf $PGDATA/postgresql.conf.orig
  20.     cp ~/postgresql.conf.${PG_MAJOR} $PGDATA/postgresql.conf
  21.     mkdir -p $PGDATA/conf.d
  22.     cp ~/00-ina-default.conf $PGDATA/conf.d/
  23.     {
  24.         echo "# allow connections via docker gateway or bridge"
  25.         echo "host    all             all             172.16.0.0/14           md5"
  26.     } >> "$PGDATA/pg_hba.conf"
  27. fi
  28.  
  29. # show PGDATA version and controldata
  30. echo "PGDATA/PGVERSION=`cat $PGDATA/PG_VERSION`"
  31.  
  32. # start postgres rdbms now
  33. exec "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement