/
wrong_side
executable file
·254 lines (185 loc) · 9.28 KB
/
wrong_side
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/env bash
## Wrong side of the tracks: Rails on Ubuntu
## Author: Mike Williamson
## Website: mikewilliamson.wordpress.com, www.dexterchief.com
## This is intended to do the heavy lifting to get a working Rails environment from a default Ubuntu install.
##
printHelpAndExit(){
echo -e "Run this script with -d mysql if you would like Mysql installed intead of Postgres."; exit 0;
}
printErrorHelpAndExit(){
echo -e "Didn't recognize the option $@. Use -h for help."; exit 1;
}
distro=`cat /etc/issue | awk '{print $1}'`; #returns 'Ubuntu'... or should.
version=`cat /etc/issue | awk '{print $2}'`; #returns something like '9.10'
database="postgres"
while getopts "d:h" optionName; do
case "$optionName" in
h)
printHelpAndExit
;;
d)
database="$OPTARG"
;;
?)
printErrorHelpAndExit
;;
esac
done
#Get the Ubuntu version that we are running on.
if [ $distro != 'Ubuntu' ]; then
echo 'This script is expecting Ubuntu. The packages that need to be installed are different on other distros.'; exit 1;
fi
apt-get update || { echo "Updating failed! Exiting!"; exit 1; } ;
apt-get --assume-yes install libnotify-bin;
notify-send "You are running $distro $version" "Downloading and installing now. Sit tight there is a lot to install.";
#
#Handle the different versions with a case statment so we can deal with different packages if needed.
#There seems to be a big difference between versions in Alpha and the difference becomes smaller as it gets closer to a final release.
#
case $version in
'9.10')
# _ __ _ _ __ _
# | |/ /__ _ _ __ _ __ ___ (_) ___ | |/ /___ __ _| | __ _
# | ' // _` | '__| '_ ` _ \| |/ __| | ' // _ \ / _` | |/ _` |
# | . \ (_| | | | | | | | | | (__ | . \ (_) | (_| | | (_| |
# |_|\_\__,_|_| |_| |_| |_|_|\___| |_|\_\___/ \__,_|_|\__,_|
#
#General packages and base Ruby stuff:
apt-get install --assume-yes build-essential openjdk-6-jre gedit-plugins vim ruby-full libopenssl-ruby1.8 ssl-cert meld python-gtksourceview || { notify-send "Problem downloading one of the main packages"; exit 1; }
#Git:
apt-get install --assume-yes git-core gitk || { notify-send "Problem installing Git"; }
#required by the Nokogiri gem:
apt-get install --assume-yes libxml2-dev libxslt1-dev|| { notify-send "Problem installing packages." "Nokogiri and the gems that depend on it (sanitize and mechanize) will be broken."; }
#Required by libnotify gem:
apt-get install --assume-yes libnotify1 || { notify-send "Problem installing libnotify"; }
#Required by Heroku/Taps gem:
apt-get install --assume-yes libsqlite3-dev sqlite3-doc || { notify-send "Problem installing Sqlite." "Taps gem will fail."; }
#RMagick gem:
#uncomment the line below if you want to use RMagick. You will also need to run "sudo gem install rmagick" later as well.
#apt-get install imagemagick librmagick-ruby libmagickwand-dev
notify-send "Installing $database";
case $database in
"mysql")
#required by Mysql gem:
apt-get install --assume-yes mysql-server-5.0 mysql-client-5.0 libmysqlclient-dev || { echo "Problem installing Mysql"; exit 1; }
;;
"postgres")
apt-get install postgresql postgresql-server-dev-8.4 || { echo "problem downloading one of the packages"; exit 1; }
;;
esac
;;
'10.04'|'10.10')
# _ _ _ _
#| | _ _ ___(_) __| | | | _ _ _ __ __ __
#| | | | | |/ __| |/ _` | | | | | | | '_ \\ \/ /
#| |___| |_| | (__| | (_| | | |___| |_| | | | |> <
#|_____|\__,_|\___|_|\__,_| |_____|\__, |_| |_/_/\_\
# |___/
#
# __ __ _ _ __ __ _
# | \/ | (_) | | | \/ | | |
# | \ / | __ ___ ___ __ _ ___| | __ | \ / | ___ ___ _ __ ___ __ _| |_
# | |\/| |/ _` \ \ / / '__| |/ __| |/ / | |\/| |/ _ \/ _ \ '__/ __|/ _` | __|
# | | | | (_| |\ V /| | | | (__| < | | | | __/ __/ | | (__| (_| | |_
# |_| |_|\__,_| \_/ |_| |_|\___|_|\_\ |_| |_|\___|\___|_| \___|\__,_|\__|
#
#
#Everything seems to be the same for Maverick. Sweet!
#Some basics and the Ruby stuff:
apt-get install --assume-yes build-essential gedit-plugins ruby-full libjson-ruby openjdk-6-jre libopenssl-ruby1.8 ssl-cert meld || { echo "Problem downloading one of the main packages."; exit 1; }
#Git:
apt-get install --assume-yes git-core gitk || { notify-send "Problem installing Git"; }
#Required by Nokogiri gem:
apt-get install --assume-yes libxml-ruby1.8 libxslt1-dev libxml2-dev || { notify-send "Problem installing libxml packages." "Nokogiri and the gems that depend on it (sanitize and mechanize) will be broken."; }
#Required by Heroku/Taps gem:
apt-get install --assume-yes libsqlite3-dev sqlite3-doc || { notify-send "Problem installing libsqlite3-dev." "Taps gem will fail."; }
#Required by libnotify gem:
apt-get install --assume-yes libnotify1 || { notify-send "Problem installing libnotify" "The libnotify gem obviously won't do well without it.'"; }
#RMagick gem:
#uncomment the line below if you want to use RMagick. You will also need to run "sudo gem install rmagick" later as well.
#apt-get install imagemagick librmagick-ruby libmagickwand-dev
notify-send "Installing $database";
case $database in
"mysql")
apt-get install --assume-yes mysql-server-5.1 mysql-client-5.1 libmysqlclient-dev || { notify-send "Problem installing Mysql"; exit 1; }
;;
"postgres")
apt-get install --assume-yes postgresql postgresql-server-dev-8.4 || { echo "problem installing Postgres"; exit 1; }
;;
esac
;;
*)
echo "$distro $version is not supported."; exit 1;
;;
esac
#
#The rest if the install is the same for both versions...
#
# _ _ _ _
#| \ | | ___| |_| |__ ___ __ _ _ __ ___
#| \| |/ _ \ __| '_ \ / _ \/ _` | '_ \/ __|
#| |\ | __/ |_| |_) | __/ (_| | | | \__ \
#|_| \_|\___|\__|_.__/ \___|\__,_|_| |_|___/
#
#cd somewhere reasonable
cd $HOME
notify-send "Downloading Netbeans 6.9.1";
wget http://download.netbeans.org/netbeans/6.9.1/final/bundles/netbeans-6.9.1-ml-ruby-linux.sh
chown -R $SUDO_USER ~/netbeans-6.9.1-ml-ruby-linux.sh
chgrp -R $SUDO_USER ~/netbeans-6.9.1-ml-ruby-linux.sh
chmod +x netbeans-6.9.1-ml-ruby-linux.sh
notify-send "Installing Netbeans 6.9.1" "It can take a while to install and it dosen't look like its doing anything. Sit tight. You will find an icon on your desktop afterwards.";
su $SUDO_USER -c './netbeans-6.9.1-ml-ruby-linux.sh --silent'
# ____ _ ____
#| _ \ _ _| |__ _ _ / ___| ___ _ __ ___ ___
#| |_) | | | | '_ \| | | | | _ / _ \ '_ ` _ \/ __|
#| _ <| |_| | |_) | |_| | |_| | __/ | | | | \__ \
#|_| \_\\__,_|_.__/ \__, |\____|\___|_| |_| |_|___/
# |___/
notify-send "Going to get a fresh ruby-gems." "Downloading the latest version from rubyforge."
echo -e "\r\n\r\nGoing to get a fresh ruby-gems...\r\n\r\n"
cd $HOME
wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz || { echo "Couldn't download ruby-gems!"; exit 1; }
tar -xvf rubygems-1.3.7.tgz || { echo "tar problems"; exit 1; }
chmod +x rubygems-1.3.7/setup.rb
ruby rubygems-1.3.7/setup.rb
echo -e "\r\n\r\nCleaning up a little...\r\n\r\n"
rm $HOME/rubygems-1.3.7.tgz
rm -Rf $HOME/rubygems-1.3.7
##Create some symlinks so we can use the gem command without whining...
ln -s /usr/bin/gem1.8 /usr/local/bin/gem
ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
ln -s /usr/bin/ri1.8 /usr/local/bin/ri
ln -s /usr/bin/irb1.8 /usr/local/bin/irb
gem update --system
#Rubygems.org/Gemcutter is the place to get all gems now.
gem install gemcutter
notify-send "Installing gems." "You may want to go have a nap. You may see some errors, but those are just for the rdocs an won't effect the gems themselves."
#Feel free to add any gems you want here:
#Will need to think about adding some versions here as well when working on older projects.
gem install taps heroku haml ruby-debug-ide ruby-debug clickatell mongrel thin mocha devise libnotify activemerchant nokogiri sanitize mechanize will_paginate nokogiri omniauth
#installing the gem for the selected database
case $database in
"mysql")
gem install mysql
;;
"postgres")
gem install pg
;;
esac
#gem install rmagick
notify-send "Installing Ruby on Rails." "Rails 3 is the version that is being installed."
#
#Uncomment the Rails versions you want installed or add others.
#They will install side by side and you projects will use the one the need (whatever is specified in the environment.rb).
#if you need to create a new project using an old version of rails you need to specify the rails version like this: rails _2.1.0_ projectname
#gem install rails -v 1.2.3 --include-dependencies
#gem install rails -v 2.1 --include-dependencies
#gem install rails -v 2.3.9 --include-dependencies
#Rails 3.
gem install rails
echo -e "\r\n\r\nHere are the gems installed:\r\n\r\n"
gem list
notify-send "Welcome to the wrong side of the tracks." "Everything is setup and ready to go. Enjoy."