-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathstart-db-in-docker.sh
More file actions
executable file
·50 lines (41 loc) · 1.14 KB
/
start-db-in-docker.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.14 KB
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
48
49
50
#!/bin/bash
set -e -u
SCRIPT_PATH="$(cd "$(dirname "${0}")" && pwd)"
function bootDB {
db="$1"
if [ "${db}" = "postgres" ]; then
launchDB="(/postgres-entrypoint.sh postgres &> /var/log/postgres-boot.log) &"
testConnection="psql -h localhost -U postgres -c '\conninfo'"
elif [ "${db}" = "mysql" ] || [ "${db}" = "mysql-5.6" ] || [ "${db}" = "mysql8" ]; then
launchDB="(MYSQL_ROOT_PASSWORD=password /mysql-entrypoint.sh mysqld &> /var/log/mysql-boot.log) &"
testConnection="mysql -h localhost -u root -D mysql -e '\s;' --password='password'"
else
echo "skipping database"
return 0
fi
echo -n "booting ${db}"
eval "$launchDB"
for _ in $(seq 1 60); do
if eval "${testConnection}" &> /dev/null; then
echo "connection established to ${db}"
return 0
fi
echo -n "."
sleep 1
done
eval "${testConnection}" || true
echo "unable to connect to ${db}"
exit 1
}
function moreSetup {
apt-get update
apt-get install -y libpq-dev default-libmysqlclient-dev
bundle install
rake db:create
}
cd /cloud_controller_ng
export GOPATH=$PWD
bootDB "${DB:-"notset"}"
moreSetup
set +e
exec /bin/bash "$@"