This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
402 lines (297 loc) · 15 KB
/
Vagrantfile
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# -*- mode: ruby -*-
# vi: set ft=ruby :
# here's a shell script to get stuff set up
$install_provisioning = <<SCRIPT_TERMINATOR
# now in shell script..
echo ''
echo ' *************************************************************'
echo ' ****************************** installing OS-level stuff... '
echo ' *************************************************************'
yum install -y yum-plugin-priorities
# wget -nv http://sherkin.justhub.org/el6/RPMS/x86_64/justhub-release-2.0-4.0.el6.x86_64.rpm
# wget -nv http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget -nv http://elgis.argeo.org/repos/6/elgis-release-6-6_0.noarch.rpm
# rpm -Uvh justhub-release-*.rpm epel-release-6*.rpm elgis-release-*.rpm
yum -y install epel-release
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
yum repolist
yum install -y supervisor
/sbin/chkconfig supervisord on
service supervisord start
yum install -y git
echo ''
echo ' *************************************************************'
echo ' ******************************** installing python tools... '
echo ' *************************************************************'
# pip and setuptools
yum -y install python-pip
pip install --upgrade pip
# virtualenv
pip install virtualenv
echo ''
echo ' *************************************************************'
echo ' ******************************** installing pandoc & tex... '
echo ' *************************************************************'
yum -y install pandoc
### can't get yum's texlive to actually compile pandoc's latex output.
yum install -y texlive texlive-latex texlive-xetex
__=" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ disabling stuff.. @@@
### try a manual install of texlive
wget -nv http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -zxvf install-tl-unx.tar.gz
pushd install-tl-unx*
./install-tl --profile=/var/climaswebapp/texlive-install.profile
popd
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ..end of disabler @@@"
echo ''
echo ' *************************************************************'
echo ' ************************************** installing CliMAS... '
echo ' *************************************************************'
# on a vagrant machine, the project dir is shared in at /vagrant,
# which is a bit vagrant-specific for me to add that path to the
# example ini files. Instead this Vagrantfile maps the
# project's ./webapp/ dir to /var/climaswebapp/ on the VM, and uses
# that as the path for the production ini file.
# install CliMAS
pushd /var/climaswebapp
sudo -u vagrant virtualenv .
sudo -u vagrant ./bin/pip install setuptools --upgrade
## this stuff gets run in another provisioning script..
# sudo -u vagrant ./bin/python ./setup.py develop
# # make the database (needs replacing for the real thing)
# pushd climasng/db/sqlbuilder
# sudo -u vagrant ./builddb.sh
# cp climasng.sqlite ..
# popd
popd
# add climas to supervisord.conf
echo "[program:climas]" >> /etc/supervisord.conf
echo "command=/var/climaswebapp/bin/pserve /var/climaswebapp/virtual.ini" >> /etc/supervisord.conf
echo "priority=999" >> /etc/supervisord.conf
echo "autostart=true" >> /etc/supervisord.conf
echo "autorestart=true" >> /etc/supervisord.conf
echo "startsecs=10" >> /etc/supervisord.conf
echo "startretries=3" >> /etc/supervisord.conf
echo "exitcodes=0,2" >> /etc/supervisord.conf
echo "stopsignal=QUIT" >> /etc/supervisord.conf
echo "stopwaitsecs=10" >> /etc/supervisord.conf
echo "user=vagrant" >> /etc/supervisord.conf
echo "log_stdout=true" >> /etc/supervisord.conf
echo "log_stderr=true" >> /etc/supervisord.conf
echo "logfile=/var/log/climas.log" >> /etc/supervisord.conf
echo "logfile_maxbytes=1MB" >> /etc/supervisord.conf
echo "logfile_backups=10" >> /etc/supervisord.conf
echo "" >> /etc/supervisord.conf
service supervisord restart
echo ''
SCRIPT_TERMINATOR
# ============================================================================================================
# boot provisioning
$boot_provisioning = <<SCRIPT_TERMINATOR
# install CliMAS
pushd /var/climaswebapp
sudo -u vagrant ./bin/python ./setup.py develop
# make the database (needs replacing for the real thing)
pushd climasng/db/sqlbuilder
sudo -u vagrant ./builddb.sh
cp climasng.sqlite ..
popd
popd
service supervisord restart
SCRIPT_TERMINATOR
# ============================================================================================================
$dummy = <<SCRIPT_TERMINATOR
echo ''
echo ' *************************************************************'
echo ' ********************************* installing viz prereqs... '
echo ' *************************************************************'
yum install -y libpng libpng-devel freetype gd gd-devel
yum install -y zlib giflib-devel gcc wget
yum install -y proj proj-devel python-devel
#### yum install -y proj
#### compile proj, yum install doesn't work for some reason?
# wget -nv http://download.osgeo.org/proj/proj-4.8.0.tar.gz
# tar -zxvf proj-4.8.0.tar.gz
# pushd proj-4.8.0
# ./configure
# make
# make check
# make install
# popd
### add proj path to everyone's environment
echo "" >> /etc/bashrc
echo 'export PROJ_LIB=/usr/local/share/proj/' >> /etc/bashrc
## DOESN'T WORK mapserver still doesn't know where proj is.
## See later for additonal attempts to fix this.
yum install -y libcurl agg agg-devel readline-devel zlib-devel
yum install -y libxml2-devel geos-devel gcc-c++ curl-devel
yum install -y libtiff libgeotiff libjpeg geos libxml2
# wget -nv http://proj.badc.rl.ac.uk/cedaservices/raw-attachment/ticket/670/armadillo-3.800.2-1.el6.x86_64.rpm
# yum localinstall -y armadillo-3*.rpm
yum install -y gdal gdal-devel
# scipy needs this..
yum install -y atlas atlas-devel blas blas-devel lapack lapack-devel
echo ''
echo ' *************************************************************'
echo ' ***************************************** installing viz... '
echo ' *************************************************************'
# install bccvl visualiser
mkdir /var/bccvlviz
chown vagrant:vagrant /var/bccvlviz
sudo -u vagrant git clone https://github.com/jcu-eresearch/BCCVL_Visualiser.git /var/bccvlviz
pushd /var/bccvlviz/BCCVL_Visualiser
sudo -u vagrant virtualenv .
sudo -u vagrant ./bin/pip install setuptools --upgrade
# sudo -u vagrant ./bin/pip install numpy==1.8.2
sudo -u vagrant ./bin/pip install numpy
sudo -u vagrant curl https://bootstrap.pypa.io/bootstrap-buildout.py > bootstrap.py
sudo -u vagrant cp /vagrant/vagrant-setup/versions.cfg ./buildout.d
sudo -u vagrant cp /vagrant/vagrant-setup/gis_compile.cfg ./buildout.d
sudo -u vagrant ./bin/python ./bootstrap.py
sudo -u vagrant ./bin/buildout
popd
# add visualiser to supervisord.conf
echo "[program:bccvlviz]" >> /etc/supervisord.conf
echo "command=/var/bccvlviz/BCCVL_Visualiser/bin/pserve /var/bccvlviz/BCCVL_Visualiser/development.ini" >> /etc/supervisord.conf
echo "priority=999" >> /etc/supervisord.conf
echo "autostart=true" >> /etc/supervisord.conf
echo "autorestart=true" >> /etc/supervisord.conf
echo "startsecs=10" >> /etc/supervisord.conf
echo "startretries=3" >> /etc/supervisord.conf
echo "exitcodes=0,2" >> /etc/supervisord.conf
echo "stopsignal=QUIT" >> /etc/supervisord.conf
echo "stopwaitsecs=10" >> /etc/supervisord.conf
echo "user=vagrant" >> /etc/supervisord.conf
echo "log_stdout=true" >> /etc/supervisord.conf
echo "log_stderr=true" >> /etc/supervisord.conf
echo "logfile=/var/log/bccvlviz.log" >> /etc/supervisord.conf
echo "logfile_maxbytes=1MB" >> /etc/supervisord.conf
echo "logfile_backups=10" >> /etc/supervisord.conf
## mapserver needs to know where to find proj. This sets the
## env var that mapserver checks to get the proj path.
# echo 'environment = PROJ_LIB="/usr/local/share/proj/"' >> /etc/supervisord.conf
# echo "" >> /etc/supervisord.conf
## STILL DOESN'T WORK mapserver still can't find it. See below
## Okay so edit the frickin mapfile to add a config line
## specifying where the frickin proj projections are.
cp /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map.backup
sed -n 'H;${x;s/^\\n//;s/MAP\\s*\\n/&\\n CONFIG "PROJ_LIB" "\\/usr\\/local\\/share\\/proj\\/"\\n\\n/;p;}' /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map.backup > /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map
service supervisord restart
echo ''
echo ' *************************************************************'
echo ' ********************************* installing viz prereqs... '
echo ' *************************************************************'
yum install -y libpng libpng-devel freetype gd gd-devel
yum install -y zlib giflib-devel gcc
#### yum install -y proj
#### compile proj, yum install doesn't work for some reason?
wget -nv http://download.osgeo.org/proj/proj-4.8.0.tar.gz
tar -zxvf proj-4.8.0.tar.gz
pushd proj-4.8.0
./configure
make
make check
make install
popd
### add proj path to everyone's environment
# echo "" >> /etc/bashrc
# echo 'export PROJ_LIB=/usr/local/share/proj/' >> /etc/bashrc
## DOESN'T WORK mapserver still doesn't know where proj is.
## See later for additonal attempts to fix this.
yum install -y libcurl agg agg-devel readline-devel zlib-devel
yum install -y libxml2-devel geos-devel gcc-c++ curl-devel
yum install -y libtiff libgeotiff libjpeg geos libxml2
wget -nv http://proj.badc.rl.ac.uk/cedaservices/raw-attachment/ticket/670/armadillo-3.800.2-1.el6.x86_64.rpm
yum localinstall -y armadillo-3*.rpm
yum install -y gdal gdal-devel
# scipy needs this..
yum install -y atlas atlas-devel blas blas-devel lapack lapack-devel
echo ''
echo ' *************************************************************'
echo ' ***************************************** installing viz... '
echo ' *************************************************************'
# install bccvl visualiser
mkdir /var/bccvlviz
chown vagrant:vagrant /var/bccvlviz
sudo -u vagrant git clone https://github.com/jcu-eresearch/BCCVL_Visualiser.git /var/bccvlviz
pushd /var/bccvlviz/BCCVL_Visualiser
sudo -u vagrant /usr/local/bin/virtualenv-2.7 .
sudo -u vagrant ./bin/pip2.7 install setuptools --upgrade
sudo -u vagrant ./bin/pip2.7 install numpy==1.8.2
sudo -u vagrant ./bin/python2.7 ./bootstrap.py
sudo -u vagrant ./bin/buildout
popd
# add visualiser to supervisord.conf
echo "[program:bccvlviz]" >> /etc/supervisord.conf
echo "command=/var/bccvlviz/BCCVL_Visualiser/bin/pserve /var/bccvlviz/BCCVL_Visualiser/development.ini" >> /etc/supervisord.conf
echo "priority=999" >> /etc/supervisord.conf
echo "autostart=true" >> /etc/supervisord.conf
echo "autorestart=true" >> /etc/supervisord.conf
echo "startsecs=10" >> /etc/supervisord.conf
echo "startretries=3" >> /etc/supervisord.conf
echo "exitcodes=0,2" >> /etc/supervisord.conf
echo "stopsignal=QUIT" >> /etc/supervisord.conf
echo "stopwaitsecs=10" >> /etc/supervisord.conf
echo "user=vagrant" >> /etc/supervisord.conf
echo "log_stdout=true" >> /etc/supervisord.conf
echo "log_stderr=true" >> /etc/supervisord.conf
echo "logfile=/var/log/bccvlviz.log" >> /etc/supervisord.conf
echo "logfile_maxbytes=1MB" >> /etc/supervisord.conf
echo "logfile_backups=10" >> /etc/supervisord.conf
## mapserver needs to know where to find proj. This sets the
## env var that mapserver checks to get the proj path.
# echo 'environment = PROJ_LIB="/usr/local/share/proj/"' >> /etc/supervisord.conf
# echo "" >> /etc/supervisord.conf
## STILL DOESN'T WORK mapserver still can't find it. See below
## Okay so edit the frickin mapfile to add a config line
## specifying where the frickin proj projections are.
cp /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map.backup
sed -n 'H;${x;s/^\\n//;s/MAP\\s*\\n/&\\n CONFIG "PROJ_LIB" "\\/usr\\/local\\/share\\/proj\\/"\\n\\n/;p;}' /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map.backup > /var/bccvlviz/BCCVL_Visualiser/map_files/default_raster.map
service supervisord restart
echo ''
echo ' *************************************************************'
echo ' ************************ shell level provisioning all done! '
echo ' *************************************************************'
echo ''
SCRIPT_TERMINATOR
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Vagrant configuration happens here.
config.vm.box = "centos/7"
# Disable automatic box update checking? Not recommended.
# config.vm.box_check_update = false
# Port forwarding
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 10600, host: 10600
# Agent forwarding on SSH?
# config.ssh.forward_agent = true
# Share additional folders
#config.vm.synced_folder ".", "/vagrant"
config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__args: ["--verbose", "--archive", "--delete", "-z"]
config.vm.synced_folder "./webapp", "/var/climaswebapp"
# config.vm.synced_folder "./webapp", "/var/climaswebapp", type: "rsync", rsync__args: ["--verbose", "--archive", "--delete", "-z"]
config.vm.synced_folder "./testdata", "/var/climaswebapp-testdata"
# config.vm.synced_folder "./testdata", "/var/climaswebapp-testdata", type: "rsync", rsync__args: ["--verbose", "--archive", "--delete", "-z"]
# config.vm.synced_folder "/Volumes/DanielsDisk/work/CliMAS-NG/datasubset", "/var/climaswebapp-subset"
# config.vm.synced_folder "/Volumes/DanielsDisk/work/CliMAS-NG/regions-output", "/var/climaswebapp-regions"
# Provider-specific config
# Example for VirtualBox:
# config.vm.provider "virtualbox" do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
config.vm.provider :virtualbox do |vb|
# vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.name = "CliMAS Global"
vb.cpus = 1
vb.memory = 1024
end
# provision the VM via a shell script, provided inline (as a variable, set above)
config.vm.provision :shell, :inline => $install_provisioning
# setup the VM every boot
config.vm.provision :shell, :inline => $boot_provisioning, :run => "always"
end