install.sh 15.8 KB
Newer Older
1
#!/bin/bash
2
set -e
3
4
5
6
7
###################################################################################################
#################################### Open AXES Install Script #####################################
###################################################################################################
#                                                                                                 #
# This script is in charge of:                                                                    #
8
#    - installing required packages like Java, Python, Apache, FFmpeg...                          #
9
10
11
12
#    - configuring the new instance of Apache w.r.t. the need for Open AXES GUI                   #
#    - downloading MCR and classifier as well as installing them if activated when calling script #
#                                                                                                 #
# Options:                                                                                        #
13
#    --includeClassifier, can be used to also install Matlab CR and classifiers.                  #
14
15
16
17
18
19
20
#                           This requires one more space (1 Gigabyte) and takes more time for the #
#                           installation. Processing time will also be increased.                 #
#    --includeOnTheFlyClassifier, can be used to also install cpu-visor system which is able to   #
#                           learn new classifier on the fly via request on external services like #
#                           Google or Bing image search. This requires more space, install a lot  #
#                           of development libraries since compilation has to be done. As a       #
#                           result installation time will be widely increased.                    #
21
22
#    --nonInteractiveMode, can be used to assume the answer is yes to any question and to extend  #
#                           sudo session in order to ease automatic installation using tools like #
23
#                           Vagrant, Puppet or Ansible (but the Java PPA based installation).     #
24
25
26
27
#                                                                                                 #
# NB: sudo -v is used often to ensure that the sudo rights are valid along the whole script.      #
###################################################################################################

28
29


30
31
32
33
###################################################################################################
################################# First check options #############################################
###################################################################################################

34

35
36
37
38
39
aptGetFlags=
pipFlags=
addAptRepositoryFlags=
makeFlags=
matlabInstallFlags=
40
unzipFlags="-u"
41
42

while  [ $# -gt 0 ]; do
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	case $1 in
		'--includeClassifier')
			includeClassifier=true;
		;;
		'--includeOnTheFlyClassifier')
			includeOnTheFlyClassifier=true;
		;;
		'--nonInteractiveMode')
			aptGetFlags="$aptGetFlags -q -y"
			extendSudo=true
			pipFlags="$pipFlags -q"
			addAptRepositoryFlags="$addAptRepositoryFlags -y"
			makeFlags="$makeFlags -s"
			matlabInstallFlags="$matlabInstallFlags -mode silent -agreeToLicense yes"
57
			unzipFlags="$unzipFlags -o -q"
58
59
60
61
62
63
64
		;;
		*)
			echo "Parameter $1 is not handled."
			exit 80
		;;
	esac
	shift
65
done
66
67


68
69
70
71

###################################################################################################
###################################### Packages installation ######################################
###################################################################################################
72

73

74
75
# Add PPA for Oracle Java if not already there.
if ! grep -q "^deb http://ppa.launchpad.net/webupd8team/java/ubuntu" /etc/apt/sources.list /etc/apt/sources.list.d/*.list; then
76
77
	echo "Installing a personal package archive for Oracle JDK (see http://ubuntuhandbook.org/index.php/2014/02/install-oracle-java-6-7-or-8-ubuntu-14-04/ for more details)."
	sudo add-apt-repository $addAptRepositoryFlags ppa:webupd8team/java
78
fi
79

80
81
# Add PPA for FFmpeg if not already there.
if ! grep -q "^deb http://ppa.launchpad.net/jon-severinsson/ffmpeg/ubuntu" /etc/apt/sources.list /etc/apt/sources.list.d/*.list; then
82
83
	echo "Installing a personal package archive for FFmpeg (see http://doc.ubuntu-fr.org/ffmpeg for more details)."
	sudo add-apt-repository $addAptRepositoryFlags ppa:jon-severinsson/ffmpeg
84
85
fi

86

87
88
sudo apt-get $aptGetFlags update
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
89
echo "Installing needed packages through APT-GET"
90
# Java for all
91
92
sudo apt-get $aptGetFlags install oracle-java7-installer
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
93
# Python and Apache for the UI
94
95
sudo apt-get $aptGetFlags install python-pip python-dev apache2 libapache2-mod-wsgi
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
96
97
# FFmpeg needed for UI Virtual cutter, video-normaliser and shot extractor
sudo apt-get $aptGetFlags install ffmpeg
98
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
99
# Various lib needed pastec
100
sudo apt-get $aptGetFlags install libopencv-dev libmicrohttpd-dev libjsoncpp-dev curl libyaml-dev
101
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
102
103
# Various lib needed for Visor
if [[ -n "$includeOnTheFlyClassifier" ]] ; then
Yann Mombrun's avatar
Yann Mombrun committed
104
	sudo apt-get $aptGetFlags install build-essential cmake libopencv-dev libgoogle-glog-dev libbz2-dev sed gawk gfortran python-numpy
105
106
107
	if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
	sudo apt-get $aptGetFlags install libprotobuf-dev protobuf-compiler libsnappy1 libsnappy-dev libleveldb1 libleveldb-dev
	if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
108
	sudo apt-get $aptGetFlags install libopenblas-dev liblmdb-dev libzmq-dev libssl-dev hdf5-tools libhdf5-dev liblapack-dev
109
fi
110
echo "APT-GET based installation finished successfully"
111

112

113
echo "Installing needed Python packages through PIP"
114
sudo pip $pipFlags install ipython django pymongo requests jsonrpclib pyyaml celery django-celery
115
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
116
sudo pip $pipFlags install PIL --allow-external PIL --allow-unverified PIL
117
118
# A few more libs needed for cpuvisor and imsearch-tools to be installed through PIP
if [[ -n "$includeOnTheFlyClassifier" ]] ; then
Yann Mombrun's avatar
Yann Mombrun committed
119
	sudo pip $pipFlags install "numpy>=1.8.0" "matplotlib>=1.3.1" "pyzmq>=14.3.1" "gevent>=1.0.1" "protobuf>=2.5.0" scipy flask gevent-zeromq
120
fi
121
122
echo "PIP based installation finished successfully"

123

124

125
126
127
###################################################################################################
############# Configuring the GUI/LIMAS with appropriate links and permissions ####################
###################################################################################################
128
129
130


echo "Configuring GUI/LIMAS paths and permissions"
131

132
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
133
134
135
sed 's?BUNDLELOCATION?'`pwd`'?' conf/gui/axes-research.conf.tmpl > conf/gui/axes-research.conf
sudo ln -sf "$(pwd)/conf/gui/axes-research.conf" /etc/apache2/sites-enabled/axes-research.conf

136
137
sed 's?BUNDLEVERSION?'1.0.0-SNAPSHOT'?' conf/gui/defaults.py.tmpl > conf/gui/defaults.py.tmpl2
if [[ -n "$includeOnTheFlyClassifier" ]] ; then
138
139
140
	sed 's?VISUAL_SEARCH_ACTIVATED?'\'category-t\''?' conf/gui/defaults.py.tmpl2 > conf/gui/defaults.py
elif [[ -n "$includeClassifier" ]] ; then
    sed 's?VISUAL_SEARCH_ACTIVATED?'\'category-t\''?' conf/gui/defaults.py.tmpl2 > conf/gui/defaults.py
141
else
142
	sed 's?VISUAL_SEARCH_ACTIVATED?''?' conf/gui/defaults.py.tmpl2 > conf/gui/defaults.py
143
fi
144
145
146
147
148
mv -f conf/gui/defaults.py axes-research-0.8.1/axesresearch/settings/
cp conf/gui/overriding/wsgi.py axes-research-0.8.1/axesresearch/
cp conf/gui/overriding/local.py axes-research-0.8.1/axesresearch/settings/
cp conf/gui/overriding/AXES.png axes-research-0.8.1/axesresearch/ui/static/img/AXESresearch.png
cp conf/gui/overriding/model.js axes-research-0.8.1/axesresearch/ui/static/js/
149
cp conf/gui/overriding/index.html axes-research-0.8.1/axesresearch/ui/templates/
150
cp conf/gui/overriding/login.html axes-research-0.8.1/axesresearch/ui/templates/
151
cp conf/gui/overriding/search.html axesresearch/ui/static/templates/views/
152
mkdir -p axes-research-0.8.1/logs
153

154
sudo mkdir -p /var/www/html/axes-research/
155
mkdir -p data/content-manager
156
mkdir -p data/toIndex
157
mkdir -p data/mongo
158

159
touch axes-research-0.8.1/logs/axesresearch.log
160

161
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
162
sudo ln -nsf "$(pwd)/data/gui/media" /var/www/html/axes-research/media
163
sudo ln -nsf "$(pwd)/axes-research-0.8.1/axesresearch/ui/static" /var/www/html/axes-research/static
164
sudo ln -nsf "$(pwd)/data/content-manager" /var/www/html/exposed-content
165
sudo ln -nsf "$(pwd)/data/content-manager" /var/www/html/keyframes
166

167
168
169
# TODO See how to fix OPENAXES-136 here. Gui files should be rw for apache user. Content-manager and mongo for both apache and openaxes
sudo chmod 777 -Rf data/content-manager/
sudo chmod 777 -Rf data/gui/
170
sudo chmod 777 -Rf axes-research-0.8.1/
171
sudo chmod 777 -Rf data/mongo/
172

173
if [[ -n "$extendSudo" ]] ; then sudo -v ; fi
174
sudo service apache2 restart
175

176
echo "GUI and LIMAS configuration finished successfully"
177

178
179


180
181
182
###################################################################################################
###################################### Installing Pastec ##########################################
###################################################################################################
183

184

185
cd components/pastec
186
echo "Installing Pastec"
187
tar zxf visualWordsORB.tar.gz
188
chmod +x pastec
189
chmod +x pastec.sh
190
cd ..
191
echo "Pastec successfully installed"
192

193
194


195
196
197
198
###################################################################################################
######################### Installing MCR and classifiers if required ##############################
###################################################################################################

199

200
if [[ -n "$includeClassifier" ]] ; then
201
202
203
	echo "Installing Matlab Compiler Runtime. This may take a while due to both download and installation."
	mkdir -p MCR/2014a
	cd MCR/2014a
204
	wget --continue http://maven.ercim.eu/axes/com/mathworks/MCR/R2014a/MCR-R2014a-glnxa64.zip
205
	unzip $unzipFlags MCR-R2014a-glnxa64.zip
206
	./install $matlabInstallFlags -destinationFolder "$(pwd)"
207

208
	echo "Matlab Compiler Runtime successfully installed"
209
	echo "Installing KUL Ueberclassifiers. This may take a while due to download."
210

211
212
213
	cd ../..
	mkdir -p KUL
	cd KUL
214
	wget --continue http://maven.ercim.eu/axes/eu/axes/resources/ueberclass_leuven/ueberclass1537_leuven_v2014a/ueberclass_leuven-ueberclass1537_leuven_v2014a.zip
215
	unzip $unzipFlags ueberclass_leuven-ueberclass1537_leuven_v2014a.zip
216
	mkdir -p ueberclass1537_leuven_v2014a/1537class/collections
217
	echo "KUL Ueberclassifiers successfully installed"
218
219
220
221
222
223
224
	cd ..
fi


###################################################################################################
####################### Installing Visor (and dependencies) if required  ##########################
###################################################################################################
225
226


227
228
229
if [[ -n "$includeOnTheFlyClassifier" ]] ; then

	echo "Downloading, compiling and installing CPU Visor and its dependencies."
230
	cd UO
231
232

	echo "Downloading and unzipping cpuvisor."
233
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/cpuvisor-srv/0.2.3/cpuvisor-srv-0.2.3.zip
234
235
236
	unzip $unzipFlags cpuvisor-srv-0.2.3.zip
	cd cpuvisor-srv-0.2.3
	rm -r imsearch-tools
237
	PREFIX=$(pwd)
238
	mkdir -p {lib,include,build,server_data,model_data}
239
240


241
	echo "Downloading and unzpiping imsearch-tool"
242
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/imsearch-tools/1.2.1/imsearch-tools-1.2.1-8c43d9b643b5d8372be8e2147229388505528031.zip
243
244
	unzip $unzipFlags imsearch-tools-1.2.1-8c43d9b643b5d8372be8e2147229388505528031.zip
	mv imsearch-tools-master imsearch-tools
245
246


247
	echo "Downloading and compiling Boost."
248
	wget --continue http://maven.ercim.eu/axes/org/boost/boost/1.57.0/boost-1.57.0.tar.gz
249
	tar xzf boost-1.57.0.tar.gz
250
251
252
253
254
255
	cd boost_1_57_0
	./bootstrap.sh
	./b2 -q install --prefix=$PREFIX
	cd ..


256
	echo "Downloading and compiling LibLinear"
257
	wget --continue http://maven.ercim.eu/axes/tw/edu/ntu/csie/liblinear/1.96/liblinear-1.96.tar.gz
258
259
260
261
262
263
264
265
266
267
	tar xzf liblinear-1.96.tar.gz
	cd liblinear-1.96
	make
	make lib
	install -m 755 linear.h $PREFIX/include
	install -m 755 liblinear.so.2 $PREFIX/lib
	ln -sf $PREFIX/lib/liblinear.so.2 $PREFIX/lib/liblinear.so
	cd ..


268
	echo "Downloading and compiling GFlags"
269
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/gflags/2.1.1/gflags-2.1.1.zip
270
	unzip $unzipFlags gflags-2.1.1.zip
271
272
273
274
275
276
277
278
279
	cd gflags-2.1.1
	mkdir -p build
	cd build
	cmake -D CMAKE_INSTALL_PREFIX=$PREFIX -D CMAKE_CXX_FLAGS=-fPIC ../
	make -j
	make install -j
	cd ../..


280
	echo "Downloading and compiling Caffe"
281
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/caffe-dev/8f0c71cb86daaf753ea812be267fbb95b69aeabe/caffe-dev-8f0c71cb86daaf753ea812be267fbb95b69aeabe.zip
282
	unzip $unzipFlags caffe-dev-8f0c71cb86daaf753ea812be267fbb95b69aeabe.zip
283
284
285
286
287
	cd caffe-dev
	cp Makefile.config.example Makefile.config
	sed -i -e "s#INCLUDE_DIRS := \$(PYTHON_INCLUDE) /usr/local/include#INCLUDE_DIRS := \$(PYTHON_INCLUDE) /usr/local/include $PREFIX/include#" Makefile.config
	sed -i -e "s#LIBRARY_DIRS := \$(PYTHON_LIB) /usr/local/lib /usr/lib#LIBRARY_DIRS := \$(PYTHON_LIB) /usr/local/lib /usr/lib $PREFIX/lib#" Makefile.config
	sed -i -e "s/# CPU_ONLY := 1/CPU_ONLY := 1/" Makefile.config
288
	sed -i -e "s/BLAS := atlas/BLAS := open/" Makefile.config
289
290
291
292
293
294
295
296
297
298
	make all -j
	install -m 0755 build/lib/libcaffe.so $PREFIX/lib
	rm -rf $PREFIX/include/caffe
	cp -r include/caffe $PREFIX/include/caffe
	mkdir -p $PREFIX/include/caffe/proto/
	cp -r build/src/caffe/proto/*.h $PREFIX/include/caffe/proto
	cd ..
	echo "Caffe successfully installed."


299
	echo "Downloading and compiling CPP NetLib"
300
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/cpp-netlib/0.11-devel/cpp-netlib-0.11-devel-f006a799d382c048d9a1a3a33608ed197f96a812.zip
301
	unzip $unzipFlags cpp-netlib-0.11-devel-f006a799d382c048d9a1a3a33608ed197f96a812.zip
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
	cd cpp-netlib-0.11-devel
	# Fixing https://github.com/cpp-netlib/cpp-netlib/issues/381
	awk 'NR==8{print "set (CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} --param ggc-min-expand=20\")"; next}1' CMakeLists.txt > CMakeLists.txt.new
	mv CMakeLists.txt CMakeLists.txt.bak
	mv CMakeLists.txt.new CMakeLists.txt
	mkdir -p build
	cd build
	cmake -D CMAKE_INSTALL_PREFIX=$PREFIX ../
	make
	make install
	cd ../..
	echo "CPP NetLib successfully installed."


	cat > setup_env.sh <<END_OF_MESSAGE_HERE
317
318
319
320
321
322
323
export PATH=$PREFIX/bin:\$PATH
export CPLUS_INCLUDE_PATH=$PREFIX/include:\$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$PREFIX/lib:$PREFIX/lib64:\$LD_LIBRARY_PATH
export LIBRARY_PATH=$PREFIX/lib:$PREFIX/lib64:\$LIBRARY_PATH
export BOOST_ROOT=$PREFIX
export CMAKE_PREFIX_PATH=$PREFIX
export MKL_NUM_THREADS=1
324
325
326
END_OF_MESSAGE_HERE


327
	echo "Compiling CPU Visor it-self"
328
329
330
331
332
333
334
	source setup_env.sh
	cd build
	cmake ../
	make
	make install
	cd ..

335

336
337
	echo "Configuring Visor."
	rm config.prototxt
338
339
340
	sed 's?<BASE_DIR>?'$(pwd)'?' ../config.prototxt.tmpl > config.prototxt
	rm dsetpaths.txt
	touch dsetpaths.txt
341

342

343
	echo "Downloading pretrained features models."
344
	cd server_data
345
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/server_data/0.2.3/server_data-0.2.3.tar
346
	tar xf server_data-0.2.3.tar
347
348
349
	# In fact just an empty file is needed here since the dataset will be enriched incrementaly by the visor-indexing service.
	rm dsetfeats.binaryproto
	touch dsetfeats.binaryproto
350
351


352
	echo "Downloading negative images used when learning models."
353
354
	mkdir -p neg_images
	cd neg_images
355
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/neg_images/0.2.3/neg_images-0.2.3.tar
356
	tar xf neg_images-0.2.3.tar
357
	cd ../..
358

359

360
361
	echo "Downloading some pretrained features models."
	cd model_data
362
	wget --continue http://maven.ercim.eu/axes/eu/axes/visor/VGG_CpuVisor_Conf/0.2.3/VGG_CpuVisor_Conf-0.2.3.zip
363
	unzip $unzipFlags VGG_CpuVisor_Conf-0.2.3.zip
364

365

366
	cd ../..
367
fi
368
369


370
echo "Installation is finished"
371
echo "Please start OpenAXES by calling: ./openaxes.sh start"
372
echo "You can then access OpenAXES on http://localhost/openaxes using the login 'axes' and password 'axes' "