/
bootstrap_rails_environment
136 lines (77 loc) · 3.78 KB
/
bootstrap_rails_environment
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
#
# Author: Wayne E. Seguin <wayneeseguin@gmail.com>
# Licence: MIT
#
#
# This script when sourced will bootstrap a Rails development environment
# on Linux and OSX
#
# Source this file so that it will leave you in the Sites directory.
rails_version="3.0.3"
ruby_version="1.8.7"
sites_path="$HOME/Sites"
abort=false
if [[ $UID -eq 0 ]] ; then
printf "ERROR: This script may not be sourced as the root user."
abort=true
else
if [[ ! -d "$sites_path" ]]; then
mkdir -p "$sites_path"
fi
cd "$sites_path"
printf "#\n# Bootstrapping a Rails development environment!\n#\n"
if [[ "Linux" = "$(uname)" ]]; then
printf "#\n# Ensuring OS packges are installed, you will be prompted for your password.\n#\n"
if command -v aptitude || command -v apt-get ; then
sudo aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
elif command -v pacman ; then
sudo pacman -S --noconfirm gcc patch curl bison zlib readline libxml2 libxslt git autoconf diffutils patch bison make
elif command -v yum ; then
sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel
sudo yum install -y iconv-devel >/dev/null 2>&1 # NOTE: For centos 5.4 final iconv-devel might not be available :(
fi
elif [[ "Darwin" = "$(uname)" ]]; then
[[ -s /Library/Developer/Shared/XcodeTools.plist ]] || {
printf "Please Install XCode Tools before sourcing this environment bootstrap script."
abort=true
}
fi
fi
if ! $abort ; then
printf "Ensuring that git is installed...\n"
if command -v git ; then
printf "Found git! Moving right along.\n"
else
printf "=> Installing Git (git command not found)"
curl -s -L -B https://rvm.beginrescueend.com/install/git -o gitinstall
chmod +x "$PWD/gitinstall"
sudo bash "$PWD/gitinstall"
[[ -f gitinstall ]] && rm -f gitinstall
fi
printf "=> Installing RVM the Ruby enVironment Manager\n https://rvm.beginrescueend.com/rvm/install/\n"
curl -s -O -L -B https://rvm.beginrescueend.com/releases/rvm-install-head
chmod +x rvm-install-head
"$PWD/rvm-install-head"
[[ -f rvm-install-head ]] && rm -f rvm-install-head
printf "=> Setting up RVM to load with new shells.\n"
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> "$HOME/.bash_profile"
printf "=> Loading RVM"
source ~/.rvm/scripts/rvm
printf "=> Installing Ruby 1.8.7\n More information about installing rubies can be found at https://rvm.beginrescueend.com/rubies/installing/"
rvm install $ruby_version
printf "=> Using 1.8.7 and setting it as default for new shells\n More information about Rubies can be found at https://rvm.beginrescueend.com/rubies/default/\n"
rvm use $ruby_version --default
printf "=> Installing Rails 3 to the default gemset.\n More information about gemsets can be found at https://rvm.beginrescueend.com/gemsets/\n"
gem install rails --no-rdoc --no-ri
printf "=> Installing Bundler to the global gemset.\n https://rvm.beginrescueend.com/gemsets/global/\n"
rvm gemset use global
gem install bundler --no-rdoc --no-ri
rvm gemset clear
printf "=> Installing the sqlite3 Gem.\n https://rubydoc.info/gems/sqlite3/1.3.3/frames\n"
gem install sqlite3 --no-rdoc --no-ri
printf "\nRails development environment bootstrapped, please enjoy Rails!\n"
printf "\n ~Wayne E. Seguin <wayneeseguin@gmail.com>\n"
printf "P.S. You should now be able to generate a new Rails Application in ~/Sites with the command 'rails new <name>'\n"
fi
unset ruby_version rails_version sites_path