Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 136 lines (117 sloc) 4.916 kB
f80e5d0 @joshfng Adding the shell script
joshfng authored
1 #!/bin/bash
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
2 #
3 # Author: Josh Frye <joshfng>
4 # Licence: MIT
5 #
6 # Contributions from: Wayne E. Seguin <wayneeseguin@gmail.com>
7 #
f80e5d0 @joshfng Adding the shell script
joshfng authored
8
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
9 ruby_version="1.9.2"
10 ruby_version_string="1.9.2p136"
11 ruby_source_url="ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p136.tar.gz"
12 ruby_source_tar_name="ruby-1.9.2-p136.tar.gz"
13 ruby_source_dir_name="ruby-1.9.2-p136"
14 script_runner=$(whoami)
15
f80e5d0 @joshfng Adding the shell script
joshfng authored
16 shopt -s extglob
17 set -e
18
19 # Check if the user has sudo privileges.
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
20 sudo -v >/dev/null 2>&1 || { echo $script_runner has no sudo privileges ; exit 1; }
21
22 echo -e "\n\n"
23 echo "#################################"
24 echo "########## Rails Ready ##########"
25 echo "#################################"
26
27 echo -e "\n\n"
28 echo "!!! This script will update your system! Run on a fresh install only !!!"
29 echo "run tail -f ~/railsready/install.log in a new terminal to watch the install"
f80e5d0 @joshfng Adding the shell script
joshfng authored
30
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
31 # Ask if you want to build Ruby or install RVM
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
32 echo -e "\n"
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
33 echo "Build Ruby or install RVM?"
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
34 echo "=> 1. Build from souce"
35 echo "=> 2. Install RVM"
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
36 echo -n "Select your Ruby type [1 or 2]? "
37 read whichRuby
38
39 if [ $whichRuby -eq 1 ] ; then
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
40 echo -e "\n\n!!! Set to build Ruby from source and install system wide !!! \n"
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
41 elif [ $whichRuby -eq 2 ] ; then
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
42 echo -e "\n\n!!! Set to install RVM for user: $script_runner !!! \n"
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
43 else
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
44 echo -e "\n\n!!! Must choose to build Ruby or install RVM, exiting !!!"
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
45 exit 1
46 fi
47
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
48 echo -e "\n=> Creating install dir..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
49 cd && mkdir -p railsready/src && cd railsready && touch install.log
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
50 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
51
52 # Update the system before going any further
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
53 echo -e "\n=> Updating system..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
54 sudo apt-get update >> install.log && sudo apt-get -y upgrade >> install.log
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
55 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
56
57 # Install build tools
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
58 echo -e "\n=> Installing build tools..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
59 sudo apt-get -y install \
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
60 wget curl build-essential \
2447abc @joshfng Adding some packages recommended by RVM
joshfng authored
61 bison openssl zlib1g \
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
62 libxslt1.1 libssl-dev libxslt1-dev \
63 libxml2 libffi-dev libyaml-dev \
64 libxslt-dev autoconf libc6-dev \
65 libreadline6-dev zlib1g-dev >> install.log
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
66 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
67
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
68 echo -e "\n=> Installing libs needed for sqlite and mysql..."
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
69 sudo apt-get -y install libsqlite3-0 sqlite3 libsqlite3-dev libmysqlclient16-dev libmysqlclient16 >> install.log
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
70 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
71
72 # Install imagemagick
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
73 echo -e "\n=> Installing imagemagick (this may take awhile)..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
74 sudo apt-get -y install imagemagick libmagick9-dev >> install.log
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
75 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
76
77 # Install git-core
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
78 echo -e "\n=> Installing git..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
79 sudo apt-get -y install git-core >> install.log
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
80 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
81
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
82 if [ $whichRuby -eq 1 ] ; then
83 # Install Ruby
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
84 echo -e "\n=> Downloading Ruby $ruby_version_string \n"
85 cd src && wget $ruby_source_url
86 echo -e "\n==> done..."
d2cb2cb @joshfng These can use the ruby_version_string variable also.
joshfng authored
87 echo -e "\n=> Extracting Ruby $ruby_version_string"
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
88 tar -xzf $ruby_source_tar_name >> ~/railsready/install.log
89 echo "==> done..."
d2cb2cb @joshfng These can use the ruby_version_string variable also.
joshfng authored
90 echo -e "\n=> Building Ruby $ruby_version_string (this may take awhile and build output may appear on screen)..."
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
91 cd $ruby_source_dir_name && ./configure --prefix=/usr/local >> ~/railsready/install.log && make >> ~/railsready/install.log && sudo make install >> ~/railsready/install.log
92 echo "==> done..."
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
93 elif [ $whichRuby -eq 2 ] ; then
94 #thanks wayneeseguin :)
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
95 echo -e "\n=> Installing RVM the Ruby environment Manager http://rvm.beginrescueend.com/rvm/install/ \n"
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
96 curl -O -L http://rvm.beginrescueend.com/releases/rvm-install-head
97 chmod +x rvm-install-head
98 "$PWD/rvm-install-head" >> ~/railsready/install.log
99 [[ -f rvm-install-head ]] && rm -f rvm-install-head
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
100 echo -e "\n==> Setting up RVM to load with new shells."
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
101 echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> "$HOME/.bashrc"
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
102 echo "==> Loading RVM"
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
103 source ~/.rvm/scripts/rvm
104 source ~/.bashrc
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
105 echo "==> done..."
106 echo -e "\n=> Installing $ruby_version_string (this will take awhile)"
107 echo -e "=> More information about installing rubies can be found at http://rvm.beginrescueend.com/rubies/installing/ \n"
108 rvm install $ruby_version >> ~/railsready/install.log
109 echo -e "\n==> done..."
110 echo -e "\n=> Using 1.9.2 and setting it as default for new shells"
111 echo "=> More information about Rubies can be found at http://rvm.beginrescueend.com/rubies/default/"
112 rvm --default use $ruby_version
113 echo "==> done..."
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
114 else
115 echo "How did you even get here?"
116 exit 1
117 fi
f80e5d0 @joshfng Adding the shell script
joshfng authored
118
119 # Reload bash
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
120 echo -e "\n=> Reloading bashrc so ruby and rubygems are available..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
121 source ~/.bashrc
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
122 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
123
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
124 echo -e "\n=> Installing Bundler, Passenger and Rails.."
1e2bfbb @joshfng Install from source or install RVM. Thanks wayneeseguin :)
joshfng authored
125 if [ $whichRuby -eq 1 ] ; then
126 sudo gem install bundler passenger rails --no-ri --no-rdoc >> ~/railsready/install.log
127 elif [ $whichRuby -eq 2 ] ; then
128 gem install bundler passenger rails --no-ri --no-rdoc >> ~/railsready/install.log
129 fi
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
130 echo "==> done..."
f80e5d0 @joshfng Adding the shell script
joshfng authored
131
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
132 echo -e "\n#################################\n"
f80e5d0 @joshfng Adding the shell script
joshfng authored
133 echo "Installation is complete!"
134
76b2b58 @joshfng Set variables for use within script. Dramatically improve the formatt…
joshfng authored
135 echo -e "\n !!! logout and back in to access Ruby or run source ~/.bashrc !!!\n"
Something went wrong with that request. Please try again.