forked from phaza/docker-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstartup.sh
17 lines (17 loc) · 941 Bytes
/
startup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
set -e
if [ ! -f /var/lib/postgresql/9.3/main ]; then
echo "Initial startup"
mkdir -p /var/lib/postgresql/9.3/main
chmod 0700 /var/lib/postgresql/9.3/main
chown postgres /var/lib/postgresql/9.3/main
su postgres -c "/usr/lib/postgresql/9.3/bin/initdb --pgdata /var/lib/postgresql/9.3/main"
su postgres -c "/usr/lib/postgresql/9.3/bin/pg_ctl -D /var/lib/postgresql/9.3/main -o '-c config_file=/etc/postgresql/9.3/main/postgresql.conf' start"
sleep 10
echo "CREATE USER docker WITH SUPERUSER PASSWORD '$DB_PASSWORD';" | su postgres -c psql
su postgres -c "createdb -O docker docker"
su postgres -c "/usr/lib/postgresql/9.3/bin/pg_ctl -D /var/lib/postgresql/9.3/main -o '-c config_file=/etc/postgresql/9.3/main/postgresql.conf' stop"
sleep 10
fi
echo "Regular startup"
su postgres -c "/usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf"