-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart-db.sh
executable file
·47 lines (40 loc) · 930 Bytes
/
start-db.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
refresh=false
if [ "$1" = "--refresh" ] ; then
refresh=true
fi
if docker ps -f name=flagstate-db | grep flagstate-db > /dev/null ; then
if $refresh ; then
docker rm -f flagstate-db
else
echo "Already running"
exit 1
fi
fi
exists=false
if docker volume ls | grep flagstate-db > /dev/null ; then
exists=true
fi
if $refresh ; then
docker volume rm flagstate-db || true
exists=false
fi
docker run \
--detach \
--rm=true \
--name=flagstate-db \
-v flagstate-db:/var/lib/pgsql/data \
-p 7432:5432 \
-e POSTGRES_DB=flagstate \
-e POSTGRES_USER=flagstate \
-e POSTGRES_PASSWORD=mypassword \
postgres
while true ; do
if $(dirname $0)/psql.sh -l 2>/dev/null | grep flagstate ; then
break
fi
sleep 1
done
if ! $exists ; then
$(dirname $0)/psql.sh < schema.sql
fi