forked from ANXS/postgresql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
17 lines (15 loc) · 870 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
if [ ! -f /var/lib/postgresql/9.6/main/PG_VERSION ]; then
echo "The database is not there."
echo "I'll create it for you"
mkdir -p /var/lib/postgresql/9.6/main
chown postgres /var/lib/postgresql/9.6/main
sudo -u postgres /usr/lib/postgresql/9.6/bin/initdb -D /var/lib/postgresql/9.6/main
echo "Starting postgresql"
sudo -u postgres /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main/ -c config_file=/etc/postgresql/9.6/main/postgresql.conf &
#create the database using the ansible tasks
ansible-playbook -i inventory --become -c local tests/playbook.yml
else
echo "The databases exist starting postgres"
sudo -u postgres /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main/ -c config_file=/etc/postgresql/9.6/main/postgresql.conf
fi