forked from zendesk/samson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·55 lines (44 loc) · 1.04 KB
/
setup
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
51
52
53
54
55
#!/bin/sh
set -e
heading() {
echo "$1... \c";
}
bold() {
echo "\033[1m$1\033[0m"
}
pass() {
bold "DONE"
}
fail() {
bold "FAIL"
echo
}
fail_and_exit() {
fail
exit -1
}
install_gem() {
if ! gem list $1 -i > /dev/null
then
echo gem install $1
gem install $1
fi
}
try() {
heading "$1"
if eval "$2"
then
pass
else
fail_and_exit
fi
}
try "Installing bundler" "install_gem bundler"
try "Bundling" "bundle check > /dev/null || bundle --local --quiet "
echo
bold "Copying example files"
try "Creating .env" "test -e .env || (test -e custom/.env.bootstrap && cp custom/.env.bootstrap .env) || (cp .env.bootstrap .env && ./bin/decode_dot_env .env)"
try "Creating config/database.yml" "test -e config/database.yml || (test -e custom/database.yml && cp custom/database.yml config/database.yml) || cp config/database.mysql.yml.example config/database.yml"
try "Creating databases" "(test -e custom/seeds.rb && cp -f custom/seeds.rb db/seeds.rb) && false || (echo 'no pass' | bundle exec rake db:setup)"
echo
bold "Success!"