-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
bootstrap_rails_environment
132 lines (100 loc) · 3.76 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
#!/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.9"
ruby_version="1.9.1"
sites_path="$HOME/Sites"
abort=false
if (( UID == 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 [[ $MACHTYPE = *linux* ]]
then
printf "#\n# Ensuring OS packges are installed, you will be prompted for your password.\n#\n"
if command -v apt-get
then
sudo apt-get 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 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 [[ $MACHTYPE = *darwin* ]]
then
if [[ ! -s /Library/Developer/Shared/XcodeTools.plist ]]
then
printf "Please Install XCode Tools before sourcing this environment bootstrap script."
abort=true
fi
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)"
if curl -s -L -B https://rvm.io/install/git -o gitinstall
then
chmod +x "$PWD/gitinstall"
sudo bash "$PWD/gitinstall"
if [[ -f gitinstall ]]
then
rm -f gitinstall
fi
else
printf "ERROR: There was an error while attempting to install git."
exit 1
fi
fi
printf "=> Installing RVM the Ruby enVironment Manager\n https://rvm.io/rvm/install/\n"
curl -s -O -L -B https://rvm.io/releases/rvm-install-head
chmod +x rvm-install-head
"$PWD/rvm-install-head"
if [[ -f rvm-install-head ]]
then
rm -f rvm-install-head
fi
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.io/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.io/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.io/gemsets/\n"
gem install rails --no-rdoc --no-ri
printf "=> Installing Bundler to the global gemset.\n https://rvm.io/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 "
Rails development environment bootstrapped, please enjoy Rails!
~Wayne E. Seguin <wayneeseguin@gmail.com>
P.S. You should now be able to generate a new Rails Application in ~/Sites with the command 'rails new <name>'
"
fi
unset ruby_version rails_version sites_path