forked from ngageoint/hootenanny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantProvisionUbuntu1604.sh.old
executable file
·481 lines (414 loc) · 15.1 KB
/
VagrantProvisionUbuntu1604.sh.old
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
#!/usr/bin/env bash
set -e
set -x
###################################################
# VERY IMPORTANT: Set the $HOOT_HOME environment #
# variable prior to running this script if ~/hoot #
# isn't the correct location for HOOT_HOME #
###################################################
if [ -z "$HOOT_HOME" ]; then
HOOT_HOME=~/hoot
fi
echo HOOT_HOME: $HOOT_HOME
#################################################
# Common set of file versions
source $HOOT_HOME/VagrantProvisionVars.sh
#
# Initial basic provisioning script for Ubuntu1604
#
VMUSER=`id -u -n`
echo USER: $VMUSER
VMGROUP=`groups | grep -o $VMUSER`
echo GROUP: $VMGROUP
cd ~
source ~/.profile
#To get rid of "dpkg-preconfigure: unable to re-open stdin: No such file or directory" warnings
export DEBIAN_FRONTEND=noninteractive
if [ -f /etc/apt/apt.conf.d/70debconf ]; then
sudo sed -i 's/ --apt//' /etc/apt/apt.conf.d/70debconf
fi
echo "Updating OS..."
sudo apt-get -qq update > Ubuntu_upgrade.txt 2>&1
sudo apt-get -q -y upgrade >> Ubuntu_upgrade.txt 2>&1
sudo apt-get -q -y dist-upgrade >> Ubuntu_upgrade.txt 2>&1
echo "### Setup NTP..."
sudo apt-get -q -y install ntp
sudo service ntp stop
sudo ntpd -gq
sudo service ntp start
if ! java -version 2>&1 | grep --quiet $JDK_VERSION; then
echo "### Installing Java 8..."
echo "$JDK_MD5 $JDK_TAR" > ./jdk.md5
if [ ! -f ./$JDK_TAR ] || ! md5sum -c ./jdk.md5; then
echo "Downloading ${JDK_TAR}...."
sudo wget --quiet --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" $JDK_URL
echo "Finished download of ${JDK_TAR}"
fi
sudo mkdir -p /usr/lib/jvm
sudo rm -rf /usr/lib/jvm/oracle_jdk8
sudo tar -xzf ./$JDK_TAR
sudo chown -R root:root ./jdk$JDK_VERSION
sudo mv -f ./jdk$JDK_VERSION /usr/lib/jvm/oracle_jdk8
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/oracle_jdk8/jre/bin/java 9999
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/oracle_jdk8/bin/javac 9999
echo "### Done with Java 8 install..."
fi
if [ ! -f /etc/apt/sources.list.d/pgdg.list ]; then
echo "### Adding PostgreSQL repository to apt..."
sudo bash -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ '$(lsb_release -cs)'-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get -qq -y update >> Ubuntu_upgrade.txt 2>&1
sudo apt-get -q -y upgrade >> Ubuntu_upgrade.txt 2>&1
fi
echo "### Installing dependencies from repos..."
sudo apt-get -q -y install \
asciidoc \
automake \
ccache \
curl \
dblatex \
docbook-xml \
doxygen \
g++ \
gdb \
git \
git-core \
gnuplot \
graphviz \
htop \
lcov \
libappindicator1 \
libboost-all-dev \
libboost-dev \
libcppunit-dev \
libcv-dev \
libgeos++-dev \
libicu-dev \
liblog4cxx10-dev \
libnewmat10-dev \
libogdi3.2-dev \
libopencv-dev \
libpq-dev \
libproj-dev \
libprotobuf-dev \
libqt4-dev \
libqt4-sql-psql \
libqt4-sql-sqlite \
libqtwebkit-dev \
libstxxl-dev \
libv8-dev \
maven \
node-gyp \
openssh-server \
patch \
pgadmin3 \
postgresql-9.5 \
postgresql-client-9.5 \
postgresql-contrib-9.5 \
postgresql-9.5-postgis-2.3 \
postgresql-9.5-postgis-scripts \
postgresql-client-9.5 \
protobuf-compiler \
python \
python-dev \
python-matplotlib \
python-pip \
python-setuptools \
ruby \
ruby-dev \
source-highlight \
swig \
texinfo \
unzip \
w3m \
x11vnc \
xsltproc \
xvfb \
zlib1g-dev \
> Ubuntu_install.txt 2>&1
# Need to check these:
# libjson-spirit-dev \
# libxerces-c28 \
# texlive-lang-arabic \
# texlive-lang-cyrillic \
# texlive-lang-hebrew \
echo "##### NodeJs #####"
NODE_VERSION=8.9.3
# Install the binary version of NodeJs for some uses (including npm)
cd ~
wget --quiet https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz
tar xf node-v${NODE_VERSION}-linux-x64.tar.xz
cd node-v${NODE_VERSION}-linux-x64
sudo cp -r bin /usr/
sudo cp -r include /usr/
sudo cp -r lib /usr/
sudo cp -r share /usr/
# Build the shared library version of NodeJs for hootenanny
cd ~
wget --quiet https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.tar.gz
tar xf node-v${NODE_VERSION}.tar.gz
cd node-v${NODE_VERSION}
# Fix an error that screws up our codebase
sed -i 's/Local<Object> json_object/Local<Value> json_object/g' deps/v8/include/v8.h
sed -i 's/Local<Object> json_object/Local<Value> json_object/g' deps/v8/src/api.cc
./configure --shared --prefix=/usr >> ~/centos_install.txt
make -j$(nproc) >> ~/centos_install.txt
sudo make install >> ~/centos_install.txt
if [ -f /usr/lib/libnode.so.?? ]; then
sudo ln -s /usr/lib/libnode.so.?? /usr/lib/libnode.so
else
sudo ln -s /usr/bin/libnode.so.?? /usr/lib/libnode.so
fi
if ! dpkg -l | grep --quiet dictionaries-common; then
# See /usr/share/doc/dictionaries-common/README.problems for details
# http://www.linuxquestions.org/questions/debian-26/dpkg-error-processing-dictionaries-common-4175451951/
sudo apt-get -q -y install dictionaries-common >> Ubuntu_upgrade.txt 2>&1
sudo /usr/share/debconf/fix_db.pl
sudo apt-get -q -y install wamerican-insane >> Ubuntu_upgrade.txt 2>&1
sudo /usr/share/debconf/fix_db.pl
sudo dpkg-reconfigure -f noninteractive dictionaries-common
fi
sudo apt-get -y autoremove
echo "### Configuring environment..."
if ! grep --quiet "export HOOT_HOME" ~/.profile; then
echo "Adding hoot home to profile..."
echo "export HOOT_HOME=$HOOT_HOME" >> ~/.profile
echo "export PATH=\$PATH:\$HOOT_HOME/bin" >> ~/.profile
source ~/.profile
fi
if ! grep --quiet "export JAVA_HOME" ~/.profile; then
echo "Adding Java home to profile..."
echo "export JAVA_HOME=/usr/lib/jvm/oracle_jdk8" >> ~/.profile
source ~/.profile
else
sed -i '/^export JAVA_HOME=.*/c\export JAVA_HOME=\/usr\/lib\/jvm\/oracle_jdk8' ~/.profile
fi
if ! grep --quiet "PATH=" ~/.profile; then
echo "Adding path vars to profile..."
echo "export PATH=\$PATH:\$JAVA_HOME/bin:~/bin:$HOOT_HOME/bin" >> ~/.profile
source ~/.profile
fi
# Use RVM to install the desired Ruby version, and then install
# the bundler at the desired version.
$HOOT_HOME/scripts/ruby/rvm-install.sh
$HOOT_HOME/scripts/ruby/bundler-install.sh
# Install gems with bundler and strict versioning (see Gemfile)
$RVM_HOME/bin/rvm $RUBY_VERSION_HOOT do bundle install
# Make sure that we are in ~ before trying to wget & install stuff
cd ~
# Install Google Chrome and ChromeDriver.
$HOOT_HOME/scripts/chrome/chrome-install.sh
$HOOT_HOME/scripts/chrome/driver-install.sh
sudo apt-get autoremove -y
if [ ! -f bin/osmosis ]; then
echo "### Installing Osmosis"
mkdir -p ~/bin
if [ ! -f osmosis-latest.tgz ]; then
wget --quiet http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-latest.tgz
fi
mkdir -p ~/bin/osmosis_src
tar -zxf osmosis-latest.tgz -C ~/bin/osmosis_src
ln -s ~/bin/osmosis_src/bin/osmosis ~/bin/osmosis
fi
if ! $( hash ogrinfo >/dev/null 2>&1 && ogrinfo --formats | grep --quiet FileGDB ); then
if [ ! -f gdal-${GDAL_VERSION}.tar.gz ]; then
echo "### Downloading GDAL $GDAL_VERSION source..."
wget --quiet http://download.osgeo.org/gdal/$GDAL_VERSION/gdal-${GDAL_VERSION}.tar.gz
fi
if [ ! -d gdal-${GDAL_VERSION} ]; then
echo "### Extracting GDAL $GDAL_VERSION source..."
tar zxfp gdal-${GDAL_VERSION}.tar.gz
fi
FGDB_VERSION2=`echo $FGDB_VERSION | sed 's/\./_/g;'`
# FGDB 1.5 is required to compile using g++ >= 5.1
# https://trac.osgeo.org/gdal/wiki/FileGDB#HowtodealwithGCC5.1C11ABIonLinux
if [ ! -f FileGDB_API_${FGDB_VERSION2}-64gcc51.tar.gz ]; then
echo "### Downloading FileGDB API source..."
wget --quiet $FGDB_URL/FileGDB_API_${FGDB_VERSION2}-64gcc51.tar.gz
fi
if [ ! -d /usr/local/FileGDB_API/lib ]; then
echo "### Extracting FileGDB API source & installing lib..."
sudo mkdir -p /usr/local/FileGDB_API && sudo tar xfp FileGDB_API_${FGDB_VERSION2}-64gcc51.tar.gz --directory /usr/local/FileGDB_API --strip-components 1
sudo sh -c "echo '/usr/local/FileGDB_API/lib' > /etc/ld.so.conf.d/filegdb.conf"
fi
echo "### Building GDAL $GDAL_VERSION w/ FileGDB..."
export PATH=/usr/local/lib:/usr/local/bin:$PATH
cd gdal-${GDAL_VERSION}
touch config.rpath
echo "GDAL: configure"
./configure --quiet --with-static-proj4 --with-fgdb=/usr/local/FileGDB_API --with-pg=/usr/bin/pg_config --with-python
echo "GDAL: make"
make -sj$(nproc) > GDAL_Build.txt 2>&1
echo "GDAL: install"
sudo make -s install >> GDAL_Build.txt 2>&1
cd swig/python
echo "GDAL: python build"
python setup.py build >> GDAL_Build.txt 2>&1
echo "GDAL: python install"
sudo python setup.py install >> GDAL_Build.txt 2>&1
sudo ldconfig
cd ~
# Update the GDAL_DATA folder in ~/.profile
if ! grep --quiet GDAL_DATA ~/.profile; then
echo "Adding GDAL data path to profile..."
echo "export GDAL_DATA=`gdal-config --datadir`" >> ~/.profile
source ~/.profile
fi
fi
# we need a newer version of glpk than what's in the repos
if dpkg -l | grep --quiet glpk; then
echo "### Removing repo version of GLPK..."
sudo apt-get -q -y remove libglpk-dev
sudo apt-get autoremove -y
fi
cd $HOOT_HOME
# need to source this to run glpsol
source ./SetupEnv.sh
cd ..
# check to see if a version previously compiled from source different than the one
# we're trying to install needs to first be removed
if glpsol | grep --quiet v; then
INSTALLED_GLPK_VERSION=`glpsol | grep v | awk '{print $5}' | sed 's/v//g'`
#echo "INSTALLED_GLPK_VERSION: " $INSTALLED_GLPK_VERSION
#echo "GLPK_VERSION: " $GLPK_VERSION
if [ $INSTALLED_GLPK_VERSION != $GLPK_VERSION ]; then
if [ -d glpk-${INSTALLED_GLPK_VERSION} ]; then
echo "### Removing GLPK $INSTALLED_GLPK_VERSION ..."
cd glpk-${INSTALLED_GLPK_VERSION}
sudo make -s uninstall >> GLPK_Build.txt 2>&1
cd ..
fi
fi
fi
# download and install the specified version
if [ ! -f glpk-${GLPK_VERSION}.tar.gz ]; then
echo "### Downloading GLPK $GLPK_VERSION source..."
wget --quiet http://ftp.gnu.org/gnu/glpk/glpk-${GLPK_VERSION}.tar.gz
fi
if ! glpsol | grep --quiet $GLPK_VERSION; then
echo "### Extracting GLPK $GLPK_VERSION source..."
tar zxfp glpk-${GLPK_VERSION}.tar.gz
echo "### Building GLPK $GLPK_VERSION..."
cd glpk-${GLPK_VERSION}
echo "GLPK: configure"
./configure --quiet
echo "GLPK: make"
sudo make -sj$(nproc) > GLPK_Build.txt 2>&1
echo "GLPK: install"
sudo make -s install >> GLPK_Build.txt 2>&1
fi
if ! mocha --version &>/dev/null; then
echo "### Installing mocha for plugins test..."
sudo npm install --silent -g mocha
# Clean up after the npm install
sudo rm -rf ~/tmp/*
fi
sudo apt -y -qq remove postgresql-9.6
sudo apt -y -qq autoremove
# If the DB encoding isn't correcct, delete and recreate the DB.
if ! sudo -u postgres psql $DB_NAME -c "SHOW SERVER_ENCODING" | grep UTF8; then
echo "Now stop the postgresql instance so we can recreate the DB w/ UTF8 encoding."
sudo service postgresql stop
sudo rm -rf /var/lib/postgresql/9.5/main/ && sudo -u postgres /usr/lib/postgresql/9.5/bin/initdb -E UTF8 -D /var/lib/postgresql/9.5/main/
echo "Starting postgresql back up."
sudo service postgresql start
fi
# NOTE: These have been changed to pg9.5
if ! sudo -u postgres psql -lqt | grep -i --quiet hoot; then
echo "### Creating Services Database..."
sudo -u postgres createuser --superuser hoot
sudo -u postgres psql -c "alter user hoot with password 'hoottest';"
sudo -u postgres createdb hoot --owner=hoot
sudo -u postgres createdb wfsstoredb --owner=hoot
sudo -u postgres psql -d hoot -c 'create extension hstore;'
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='wfsstoredb'" > /dev/null
sudo -u postgres psql -d wfsstoredb -c 'create extension postgis;' > /dev/null
fi
if ! grep -i --quiet HOOT /etc/postgresql/9.5/main/postgresql.conf; then
echo "### Tuning PostgreSQL..."
sudo -u postgres sed -i.bak s/^max_connections/\#max_connections/ /etc/postgresql/9.5/main/postgresql.conf
sudo -u postgres sed -i.bak s/^shared_buffers/\#shared_buffers/ /etc/postgresql/9.5/main/postgresql.conf
sudo -u postgres bash -c "cat >> /etc/postgresql/9.5/main/postgresql.conf" <<EOT
#--------------
# Hoot Settings
#--------------
max_connections = 1000
shared_buffers = 1024MB
max_files_per_process = 1000
work_mem = 16MB
maintenance_work_mem = 256MB
autovacuum = off
EOT
fi
# Update shared memory limits in OS
if ! sysctl -e kernel.shmmax | grep --quiet 1173741824; then
echo "### Setting kernel.shmmax..."
sudo sysctl -w kernel.shmmax=1173741824
sudo sh -c "echo 'kernel.shmmax=1173741824' >> /etc/sysctl.conf"
fi
if ! sysctl -e kernel.shmall | grep --quiet 2097152; then
echo "### Setting kernel.shmall..."
sudo sysctl -w kernel.shmall=2097152
sudo sh -c "echo 'kernel.shmall=2097152' >> /etc/sysctl.conf"
fi
sudo service postgresql restart
cd $HOOT_HOME
source ./SetupEnv.sh
if [ ! "$(ls -A hoot-ui)" ]; then
echo "hoot-ui is empty"
echo "init'ing and updating submodule"
git submodule init && git submodule update
fi
if dpkg -l | grep --quiet tomcat6; then
echo "Disabling Tomcat 6 service"
# Shut down tomcat6 service
sudo service tomcat6 stop
# Deregister tomcat6 service from autostart
sudo update-rc.d -f tomcat6 remove
#uninstall Tomcat
sudo apt-get -y purge tomcat6
sudo apt-get -y autoremove
sudo rm -f /etc/default/tomcat6*
sudo rm -rf /etc/tomcat6
sudo rm -rf /usr/share/tomcat6
sudo sed -i '/^export TOMCAT6_HOME/d' ~/.profile
fi
TOMCAT_HOME=/usr/share/tomcat8
# Install Tomcat 8
$HOOT_HOME/scripts/tomcat/ubuntu/tomcat8_install.sh
# Configure Tomcat
if ! grep --quiet TOMCAT8_HOME ~/.profile; then
echo "### Adding Tomcat to profile..."
echo "export TOMCAT8_HOME=$TOMCAT_HOME" >> ~/.profile
source ~/.profile
fi
if [ -f $HOOT_HOME/conf/LocalHoot.json ]; then
echo "Removing LocalHoot.json..."
rm -f $HOOT_HOME/conf/LocalHoot.json
fi
if [ -f $HOOT_HOME/hoot-services/src/main/resources/conf/local.conf ]; then
echo "Removing services local.conf..."
rm -f $HOOT_HOME/hoot-services/src/main/resources/conf/local.conf
fi
cd ~
echo "### Installing node-export-server..."
sudo cp $HOOT_HOME/node-export-server/init.d/node-export-server /etc/init.d
sudo chmod a+x /etc/init.d/node-export-server
# Make sure all npm modules are installed
cd $HOOT_HOME/node-export-server
npm install --silent
# Clean up after the npm install
rm -rf ~/tmp/*
cd $HOOT_HOME
rm -rf $HOOT_HOME/ingest
mkdir -p $HOOT_HOME/ingest/processed
rm -rf $HOOT_HOME/upload
mkdir -p $HOOT_HOME/upload
# Update marker file date now that dependency and config stuff has run
# The make command will exit and provide a warning to run 'vagrant provision'
# if the marker file is older than this file (VagrantProvision.sh)
touch Vagrant.marker
# Now we are ready to build Hoot. The VagrantBuild.sh script will build Hoot.
# switch to auto mode and use the highest priority installed alternatives for Java.
sudo update-alternatives --auto java
sudo update-alternatives --auto javac