-
Notifications
You must be signed in to change notification settings - Fork 14
/
default.rb
333 lines (292 loc) · 9.2 KB
/
default.rb
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
%w[wget curl ack python-software-properties autoconf bison flex libyaml-dev libtool make vim].each do |pkg|
package pkg do
action :install
end
end
install_prefix = "/usr/local"
["add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y", "apt-get update"].each do |cmd|
execute cmd do
user "root"
end
end
["sudo add-apt-repository ppa:mapnik/nightly-2.0 -y", "apt-get update"].each do |cmd|
execute cmd do
user "root"
end
end
# Geo packages
%w[
libsqlite3-dev
libproj-dev
libgeos-dev
libspatialite-dev
libgeotiff-dev
libgdal-dev
gdal-bin
libmapnik-dev
mapnik-utils
python-dev
python-setuptools
python-pip
python-gdal
python-mapnik
postgresql-9.1
postgresql-server-dev-9.1
postgresql-plpython-9.1
libjson0-dev
redis-server
libxslt-dev
unzip
unp
osm2pgsql
osmosis
protobuf-compiler
libprotobuf-dev
libtokyocabinet-dev
python-psycopg2
imagemagick
libmagickcore-dev
libmagickwand-dev
].each do |pkg|
package pkg do
action :install
end
end
install_prefix = "/usr/local"
execute "apt-get update" do
user "root"
end
execute "install PostGIS 2.x" do
command <<-EOS
if [ ! -d /usr/local/src/postgis-2.0.1 ]
then
cd /usr/local/src &&
wget http://postgis.org/download/postgis-2.0.1.tar.gz &&
tar xfvz postgis-2.0.1.tar.gz &&
cd postgis-2.0.1 &&
./configure &&
make &&
make install &&
ldconfig &&
make comments-install &&
ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql &&
ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp &&
ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql &&
curl -s https://raw.github.com/gist/c83798ee55a08b7a5de5/813a2ba7543697789d2b5af6fae2cabf547cef54/pg_hba.conf -o /etc/postgresql/9.1/main/pg_hba.conf &&
curl -s https://raw.github.com/gist/bdf5accb7b328f7f596a/0f3a969132150655c861e2ea22852fdd16eac02c/postgresql.conf -o /etc/postgresql/9.1/main/postgresql.conf &&
/etc/init.d/postgresql restart &&
echo "CREATE ROLE vagrant LOGIN;" | psql -U postgres &&
echo "CREATE DATABASE vagrant;" | psql -U postgres &&
echo "ALTER USER vagrant SUPERUSER;" | psql -U postgres &&
echo "ALTER USER vagrant WITH PASSWORD 'vagrant';" | psql -U postgres &&
echo "CREATE DATABASE template_postgis;" | psql -U postgres &&
echo "CREATE EXTENSION postgis;" | psql -U postgres -d template_postgis &&
echo "CREATE EXTENSION postgis_topology;" | psql -U postgres -d template_postgis &&
echo "GRANT ALL ON geometry_columns TO PUBLIC;" | psql -U postgres -d template_postgis &&
echo "GRANT ALL ON spatial_ref_sys TO PUBLIC;" | psql -U postgres -d template_postgis
fi
EOS
action :run
user 'root'
end
ENV['PATH'] = "/home/#{node[:user]}/local:#{ENV['PATH']}"
execute "set shell to zsh" do
command "usermod -s /bin/zsh #{node[:user]}"
action :run
user "root"
end
directory "/home/#{node[:user]}/local" do
owner node[:user]
group node[:user]
mode "0755"
action :create
end
directory "/home/#{node[:user]}/local/src" do
owner node[:user]
group node[:user]
mode "0755"
action :create
end
directory "#{install_prefix}/src" do
owner "root"
group "root"
mode "0755"
action :create
end
git "ry" do
repository "git://github.com/zhm/ry.git"
reference 'master'
destination "#{install_prefix}/src/ry"
action :checkout
user "root"
end
ENV['RY_PREFIX'] = install_prefix
execute "install ry" do
cwd "#{install_prefix}/src/ry"
command <<-EOS
[ -x #{install_prefix}/bin/ry ] || PREFIX=#{install_prefix} make install
EOS
action :run
user "root"
end
execute "install ruby 1.9.3" do
command <<-EOS
[ -x #{install_prefix}/lib/ry/current/bin/ruby ] ||
#{install_prefix}/bin/ry install https://github.com/ruby/ruby/tarball/v1_9_3_195 1.9.3 --enable-shared=yes
EOS
action :run
user "root"
end
execute "setup ruby" do
command <<-EOS
export RY_PREFIX=#{install_prefix} &&
export PATH=$RY_PREFIX/lib/ry/current/bin:$PATH &&
#{install_prefix}/lib/ry/current/bin/gem update --system &&
#{install_prefix}/lib/ry/current/bin/gem install bundler
EOS
action :run
user "root"
end
git "oh-my-zsh" do
repository "git://github.com/robbyrussell/oh-my-zsh.git"
reference 'master'
destination "/home/#{node[:user]}/.oh-my-zsh"
action :checkout
user node[:user]
end
execute "install .zshrc" do
command "curl -L -o /home/#{node[:user]}/.zshrc https://raw.github.com/gist/789ba55f7ab0bf895a1c/5dc934f2737f75b306637c35258b984fc0127005/.zshrc"
action :run
user node[:user]
end
execute "install zsh theme" do
command "curl -L -o /home/#{node[:user]}/.oh-my-zsh/themes/hackbox.zsh-theme https://raw.github.com/gist/1e701eb696d8804fa19c/c729347309a79f6820f4ad6feb7b517242755510/hackbox.zsh-theme"
action :run
user node[:user]
end
git "n" do
repository "git://github.com/zhm/n.git"
reference 'master'
destination "#{install_prefix}/src/n"
action :checkout
user "root"
end
execute "install n" do
cwd "#{install_prefix}/src/n"
command <<-EOS
make install && n 0.8.9
EOS
action :run
user 'root'
end
execute "install standard node modules" do
modules = %w(coffee-script underscore node-gyp)
command modules.map {|m| "npm install -g #{m}" }.join(' && ')
action :run
user 'root'
end
# CARTODB
execute "install pip" do
command "easy_install pip"
action :run
user 'root'
end
execute "install python dependencies for CartoDB" do
command <<-EOS
pip install 'chardet==1.0.1' &&
pip install 'argparse==1.2.1' &&
pip install 'brewery==0.6' &&
pip install 'redis==2.4.9' &&
pip install 'hiredis==0.1.0' &&
pip install -e 'git+https://github.com/RealGeeks/python-varnish.git@0971d6024fbb2614350853a5e0f8736ba3fb1f0d#egg=python-varnish==0.1.2'
EOS
action :run
user 'root'
end
git "CartoDB-SQL-API" do
repository "git://github.com/Vizzuality/CartoDB-SQL-API.git"
reference 'master'
destination "#{install_prefix}/src/CartoDB-SQL-API"
action :checkout
user "root"
end
execute "setup CartoDB-SQL-API" do
command "cd #{install_prefix}/src/CartoDB-SQL-API && npm install"
end
git "Windshaft-cartodb" do
repository "git://github.com/Vizzuality/Windshaft-cartodb.git"
reference 'master'
destination "#{install_prefix}/src/Windshaft-cartodb"
action :checkout
user "root"
end
execute "setup Windshaft-cartodb" do
cwd "#{install_prefix}/src/Windshaft-cartodb"
command <<-EOS
sudo npm install
EOS
user 'root'
end
execute "start Windshaft-cartodb" do
cwd "#{install_prefix}/src/Windshaft-cartodb"
command <<-EOS
mkdir -p log pids
chown -R vagrant:vagrant log pids
[ -f pids/windshaft.pid ] && kill `cat pids/windshaft.pid`
nohup node app.js development >> #{install_prefix}/src/Windshaft-cartodb/log/development.log 2>&1 &
echo $! > #{install_prefix}/src/Windshaft-cartodb/pids/windshaft.pid
EOS
user 'root'
end
git "CartoDB" do
repository "git://github.com/Vizzuality/cartodb.git"
reference 'master'
destination "#{install_prefix}/src/cartodb"
action :checkout
user "root"
end
execute "setup cartodb" do
# strip out the ruby-debug gem from the Gemfile since it consistently causes problems and
# doesn't seem to install properly in all ruby environments and OS's.
# also, overwrite `script/create_dev_user` with a custom one that doesn't prompt
cwd "#{install_prefix}/src/cartodb"
command <<-EOS
if [ ! -f config/database.yml ]
then
chown -R vagrant:vagrant #{install_prefix}/src/cartodb
sed 's/.*gem "ruby-debug.*//g' Gemfile > Gemfile.tmp && mv Gemfile.tmp Gemfile
sed 's/^echo -n "Enter.*//g' script/create_dev_user > script/create_dev_user.tmp && mv script/create_dev_user.tmp script/create_dev_user
export RY_PREFIX=#{install_prefix} &&
export PATH=$RY_PREFIX/lib/ry/current/bin:$PATH
#{install_prefix}/lib/ry/current/bin/bundle install --binstubs &&
curl -s https://raw.github.com/gist/21c52f1eb9862a1dfffa/58cc1436d23153be0ad2502c8ed5459847c85685/app_config.yml -o config/app_config.yml &&
curl -s https://raw.github.com/gist/4c503e531fd54b3cbcec/0a435609a58e3f8401cfee5990e173b170e2cc82/database.yml -o config/database.yml &&
echo "127.0.0.1 admin.localhost.lan" | tee -a /etc/hosts &&
echo "127.0.0.1 admin.testhost.lan" | tee -a /etc/hosts &&
echo "127.0.0.1 cartodb.localhost.lan" | tee -a /etc/hosts &&
PASSWORD=cartodb ADMIN_PASSWORD=cartodb EMAIL=admin@cartodb sh script/create_dev_user cartodb
fi
EOS
user "root"
end
execute "start cartodb" do
cwd "#{install_prefix}/src/cartodb"
command <<-EOS
mkdir -p public log tmp pids
chown -R vagrant:vagrant public log tmp pids
[ -f pids/cartodb.pid ] && kill `cat pids/cartodb.pid`
export RY_PREFIX=#{install_prefix}
export PATH=$RY_PREFIX/lib/ry/current/bin:$PATH
nohup bundle exec rails server >> #{install_prefix}/src/cartodb/log/development.log 2>&1 &
echo $! > #{install_prefix}/src/cartodb/pids/cartodb.pid
EOS
user 'root'
end
execute "install imposm" do
command <<-EOS
pip install imposm.parser &&
pip install Shapely &&
pip install imposm
EOS
user 'root'
end