Arvbox fixes: use 'postgres' database when testing if a user exists. Copy
[arvados.git] / lib / arvbox / docker / service / postgres / run-service
1 #!/bin/bash
2
3 exec 2>&1
4 set -eux -o pipefail
5
6 if ! test -d /var/lib/postgresql/9.4/main ; then
7     /usr/lib/postgresql/9.4/bin/initdb -D /var/lib/postgresql/9.4/main
8     sh -c "while ! (psql postgres -c'\du' | grep '^ arvbox ') >/dev/null ; do createuser -s arvbox ; sleep 1 ; done" &
9 fi
10 mkdir -p /var/run/postgresql/9.4-main.pg_stat_tmp
11
12 rm -f /var/lib/postgresql/9.4/main/postmaster.pid
13
14 exec /usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf