forked from bobanj/railsready
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrailsready.sh
executable file
·112 lines (93 loc) · 3.37 KB
/
railsready.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
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
#!/bin/bash
#
# Rails Ready
#
# Author: Josh Frye <[email protected]>
# Licence: MIT
#
# Contributions from: Wayne E. Seguin <[email protected]>
# Contributions from: Ryan McGeary <[email protected]>
#
shopt -s nocaseglob
set -e
ruby_version="1.9.3"
script_runner=$(whoami)
railsready_path=$(cd && pwd)/railsready
log_file="$railsready_path/install.log"
control_c()
{
echo -en "\n\n*** Exiting ***\n\n"
exit 1
}
# trap keyboard interrupt (control-c)
trap control_c SIGINT
clear
echo "#################################"
echo "########## Rails Ready ##########"
echo "#################################"
#determine the distro
if [[ $MACHTYPE = *linux* ]] ; then
distro_sig=$(cat /etc/issue)
if [[ $distro_sig =~ ubuntu ]] ; then
distro="ubuntu"
if [[ $distro_sig =~ Ubuntu ]] ; then
distro="ubuntu"
elif [[ $distro_sig =~ centos ]] ; then
distro="centos"
elif [[ $distro_sig =~ "Red Hat" ]] ; then
distro="redhat"
fi
fi
echo -e "\n\n"
echo "!!! This script will update your system! Run on a fresh install only !!!"
echo "run tail -f $log_file in a new terminal to watch the install"
echo -e "\n"
echo "What this script gets you:"
echo " * An updated system"
echo " * Ruby $ruby_version"
echo " * Imagemagick"
echo " * libs needed to run Rails (sqlite, mysql, etc)"
echo " * Bundler, Passenger, and Rails gems"
echo " * Git"
echo -e "\n\n!!! Set to install RVM for user: $script_runner !!! \n"
echo -e "\n=> Creating install dir..."
cd && cd railsready && touch install.log
echo "==> done..."
echo -e "\n=> Downloading and running recipe for $distro...\n"
#Download the distro specific recipe and run it, passing along all the variables as args
cd $railsready_path/recipes && bash $distro.sh $ruby_version $railsready_path $log_file
echo -e "\n==> done running $distro specific commands..."
#now that all the distro specific packages are installed lets get Ruby
#thanks wayneeseguin :)
echo -e "\n=> Installing RVM the Ruby enVironment Manager http://rvm.beginrescueend.com/rvm/install/ \n"
curl -O -L -k https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer
chmod +x rvm-installer
"$PWD/rvm-installer" >> $log_file 2>&1
[[ -f rvm-installer ]] && rm -f rvm-installer
echo "==> done..."
echo "=> Loading RVM..."
source /etc/profile.d/rvm.sh
echo "==> done..."
echo -e "\n=> Installing Ruby $ruby_version (this will take a while)..."
echo -e "=> More information about installing rubies can be found at http://rvm.beginrescueend.com/rubies/installing/ \n"
rvm install $ruby_version >> $log_file 2>&1
echo -e "\n==> done..."
echo -e "\n=> Using $ruby_version and setting it as default for new shells..."
echo "=> More information about Rubies can be found at http://rvm.beginrescueend.com/rubies/default/"
rvm --default use $ruby_version >> $log_file 2>&1
echo "==> done..."
# Reload bash
echo -e "\n=> Reloading shell so ruby and rubygems are available..."
source /etc/profile.d/rvm.sh
echo "==> done..."
echo -e "\n=> Updating Rubygems..."
gem update --system --no-ri --no-rdoc >> $log_file 2>&1
echo "==> done..."
echo -e "\n=> Installing Bundler, Passenger and Rails..."
gem install bundler passenger rails --no-ri --no-rdoc >> $log_file 2>&1
echo "==> done..."
echo -e "\n#################################"
echo "### Installation is complete! ###"
echo -e "#################################\n"
echo -e "\n !!! logout and back in to access Ruby !!!\n"
echo -e "\n Thanks!\n-Josh\n"