-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_rails_rbenv_ruby2.2.2.sh
65 lines (57 loc) · 1.85 KB
/
install_rails_rbenv_ruby2.2.2.sh
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
#!/bin/bash
# run this command to install (without the #)
# bash <(curl -s https://raw.githubusercontent.com/future-youth-camp/snippets/master/install_rails_rbenv_ruby2.2.2.sh)
PS3='Please enter your choice: '
options=("Install ruby" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Install ruby")
# Create an empty bashrc if neeed be
if [ ! -f ~/.bashrc ]; then
touch ~/.bashrc
fi
# install rbenv
if [ ! -d ~/.rbenv/ ]; then
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'source ~/.rbenv/completions/rbenv.bash' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
else
echo 'rbenv was installed already'
fi
# clone ruby-build
if [ ! -d ~/.rbenv/plugins/ruby-build ]; then
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
fi
# reload our env for a bit
source ~/.bashrc
# install ruby
rbenv install 2.2.2
rbenv global 2.2.2
# install base gems
gem update --system
gem install bundler
gem install rails
rails new ~/test-app
rm -rf ~/test-app
# adding .railsrc config
if [ ! -f ~/.railsrc ]; then
touch ~/.railsrc
echo '--skip-bundle #skips bundle install on generating a new rails app' >> ~/.railsrc
echo '--skip-test-unit #skips making the test unit folders (rspec is better and comeon.. newbies)' >> ~/.railsrc
else
echo 'rails home config is present already. no need for install'
fi
echo '------------'
echo 'All has been installed.'
echo 'Start a new rails app with the command'
echo 'rails new'
break
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done