-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·43 lines (34 loc) · 1 KB
/
bootstrap
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
#!/usr/bin/env bash
# set -e
if [ "$1" = "-v" ]; then
exec 3>&1
else
exec 3>/dev/null
fi
banner() { echo "-----> $*" ; }
info() { echo " $*" ; }
warn() { echo ">>>>>> $*" >&2 ; }
banner "Running bundler"
export PATH=".bin:$PATH"
rm -rf .bundle
if [ $CI ]; then
bundle install --binstubs .bin --path vendor/bundle --without local development staging production "$@"
else
bundle install --binstubs .bin --path vendor/bundle "$@"
fi
if [ -f ../config/database.yml ]; then
banner "Setting up database"
info "Installing hstore extension"
{ psql -tAl -d template1 -c '\dx' | grep -E "^hstore\|" >/dev/null || \
psql -d template1 -c 'CREATE EXTENSION IF NOT EXISTS hstore'
} >&3 2>&1
info "Creating database user"
createuser -s reveille 2>&1 >> /dev/null || "psql user already created"
info "Creating databases"
bundle exec rake db:create:all
info "Running migrations"
bundle exec rake db:migrate
info "Preparing test database"
bundle exec rake db:test:prepare
fi
info "Done!"