Ticket #118: install_rasdaman.sh

File install_rasdaman.sh, 9.3 KB (added by Dimitar Misev, 13 years ago)

installs rasdaman on the osgeo-live DVD

Line 
1#!/bin/bash
2#
3# This file is part of rasdaman community.
4#
5# Rasdaman community is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# Rasdaman community is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
17#
18# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
19# rasdaman GmbH.
20#
21# For more information please see <http://www.rasdaman.org>
22# or contact Peter Baumann via <baumann@rasdaman.com>.
23#
24
25# rasdaman src to be used
26VERSION=8.3.0
27RASDAMAN_LOCATION="http://www.rasdaman.com/Download"
28RASDAMAN_TARBALL="rasdaman-$VERSION.tar.gz"
29
30# live disc's username is "user"
31USER_NAME="user"
32USER_HOME="/home/$USER_NAME"
33RASDAMAN_HOME="/usr/local/rasdaman"
34TMP="/tmp/build_rasdaman"
35
36#set the postgresql database username and password.
37# Note that if this is changed, /var/lib/tomcat6/webapps/petascope/setting.properties
38# must be modified to reflect the changes
39WCPS_DATABASE="petascopedb"
40WCPS_USER="petauser"
41WCPS_PASSWORD="UD0b9uTt"
42
43mkdir -p "$TMP"
44cd "$TMP"
45if [ ! -d "$RASDAMAN_HOME" ]; then
46 mkdir "$RASDAMAN_HOME"
47fi
48
49#get and install required packages
50PACKAGES="make autoconf automake libtool gawk flex bison \
51 g++ gcc cpp libstdc++6 libreadline-dev libssl-dev \
52 libncurses5-dev postgresql libecpg-dev libtiff4-dev libjpeg62-dev \
53 libhdf4-0 libpng12-dev libnetpbm10-dev tomcat6 php5-cgi \
54 wget libgdal1-dev openjdk-6-jdk libnetcdf-dev rpcbind"
55
56
57pkg_cleanup()
58{
59 # be careful that no other project on the disc wanted any of these!
60
61 apt-get --yes remove preview-latex-style tex-common texlive-base \
62 texlive-binaries texlive-common texlive-doc-base texlive-extra-utils \
63 texlive-latex-base texlive-latex-extra texlive-latex-recommended \
64 texlive-pictures libtool bison comerr-dev doxygen doxygen-latex \
65 flex krb5-multidev latex-xcolor libecpg-dev libjpeg62-dev \
66 libkrb5-dev libncurses5-dev libnetpbm10-dev libpng12-dev \
67 libpq-dev libreadline-dev libreadline6-dev libtiff4-dev \
68 luatex openjdk-6-jdk libgssrpc4 libkadm5clnt-mit7 libkadm5srv-mit7 \
69 libkdb5-4 libgdal1-dev libnetcdf-dev
70 # remove jdk
71 apt-get --yes remove ca-certificates-java libaccess-bridge-java \
72 libaccess-bridge-java-jni libnss3-1d openjdk-6-jdk openjdk-6-jre \
73 openjdk-6-jre-headless openjdk-6-jre-lib tzdata-java
74
75 apt-get --yes autoremove
76}
77
78
79
80apt-get update
81
82apt-key update
83
84apt-get install --no-install-recommends --assume-yes $PACKAGES
85
86if [ $? -ne 0 ] ; then
87 echo "ERROR: package install failed."
88 exit 1
89fi
90
91# symlink from the installed libdfalt
92ln -s /usr/lib/libdfalt.a /usr/lib/libdf.a
93ln -s /usr/lib/libdfalt.la /usr/lib/libdf.la
94ln -s /usr/lib/libdfalt.so /usr/lib/libdf.so
95ln -s /usr/lib/libdfalt.so.0 /usr/lib/libdf.so.0
96ln -s /usr/lib/libdfalt.so.0.0.0 /usr/lib/libdf.so.0.0.0
97ln -s /usr/lib/libmfhdfalt.a /usr/lib/libmfhdf.a
98ln -s /usr/lib/libmfhdfalt.la /usr/lib/libmfhdf.la
99ln -s /usr/lib/libmfhdfalt.so /usr/lib/libmfhdf.so
100ln -s /usr/lib/libmfhdfalt.so.0 /usr/lib/libmfhdf.so.0
101ln -s /usr/lib/libmfhdfalt.so.0.0.0 /usr/lib/libmfhdf.so.0.0.0
102
103#download and install rasdaman
104#If folder already exists skip the git clone and used cached version
105
106echo "FIXME: use a better test to avoid stale installs"
107
108if [ ! -d rasdaman ] ; then
109 #git clone git://kahlua.eecs.jacobs-university.de/rasdaman.git
110 wget -c --progress=dot:mega "$RASDAMAN_LOCATION/$RASDAMAN_TARBALL"
111 tar xzf "$RASDAMAN_TARBALL"
112fi
113
114cd "rasdaman-$VERSION"
115mkdir -p "$RASDAMAN_HOME/log"
116chown "$USER_NAME" "$RASDAMAN_HOME/log/" -R
117
118./configure --with-logdir="$RASDAMAN_HOME"/log \
119 --prefix="$RASDAMAN_HOME" --with-netcdf --with-hdf4
120
121if [ $? -ne 0 ] ; then
122 echo "ERROR: configure failed."
123 pkg_cleanup
124 exit 1
125fi
126
127make
128if [ $? -ne 0 ] ; then
129 echo "ERROR: compilation failed."
130 pkg_cleanup
131 exit 1
132fi
133
134make install
135if [ $? -ne 0 ] ; then
136 echo "ERROR: package install failed."
137 pkg_cleanup
138 exit 1
139fi
140
141# setup rasdaview
142mv "$RASDAMAN_HOME"/bin/rview "$RASDAMAN_HOME"/bin/rview.bin
143cp "$RASDAMAN_HOME"/share/rasdaman/errtxts* "$RASDAMAN_HOME"/bin/
144RASVIEWSCRIPT="$RASDAMAN_HOME"/bin/rasdaview
145echo "#!/bin/bash" > $RASVIEWSCRIPT
146echo "export RASVIEWHOME=$RASDAMAN_HOME/bin" >> $RASVIEWSCRIPT
147echo "cd $RASVIEWHOME && ./rview.bin" >> $RASVIEWSCRIPT
148chmod +x $RASVIEWSCRIPT
149
150# setup permissions
151chown "$USER_NAME" "$RASDAMAN_HOME"/bin/*
152chmod 774 "$RASDAMAN_HOME"/bin/*
153sed -i "s/RASDAMAN_USER=rasdaman/RASDAMAN_USER=$USER_NAME/g" \
154 "$RASDAMAN_HOME"/bin/create_db.sh
155
156# add rasdaman to the $PATH if not present
157if [ `grep -c $RASDAMAN_HOME/rasdaman/bin $USER_HOME/.bashrc` -eq 0 ] ; then
158 echo 'export PATH=$PATH:'$RASDAMAN_HOME/bin >> "$USER_HOME/.bashrc"
159fi
160
161#test if rasbase exists, if not create rasbase database
162test_RASBASE=$(su - $USER_NAME -c "psql --quiet --list | grep \"RASBASE \" ")
163if [ -z "$test_RASBASE" ] ; then
164 su - $USER_NAME $RASDAMAN_HOME/bin/create_db.sh
165fi
166
167
168# needed to start the RPC server
169sed -i -e 's/OPTIONS="-w"/OPTIONS="-w -i"/' /etc/init.d/rpcbind
170/etc/init.d/rpcbind restart
171
172su - "$USER_NAME" "$RASDAMAN_HOME"/bin/start_rasdaman.sh
173
174#-------------------------------------------------------------------------------
175# setup petascope
176
177# create petascope database/user
178echo creating users and metadata database
179su - $USER_NAME -c "createuser $WCPS_USER --superuser"
180su - $USER_NAME -c "psql template1 --quiet -c \"ALTER ROLE $WCPS_USER with PASSWORD '$WCPS_PASSWORD';\""
181test_WCPSDB=$(su - $USER_NAME -c "psql --quiet --list | grep \"$WCPS_DATABASE \" ")
182if [ -z "$test_WCPSDB" ] ; then
183 su - "$USER_NAME" -c "createdb -T template0 $WCPS_DATABASE"
184fi
185
186cd applications/petascope
187cp src/main/resources/settings.properties db
188sed -i "s/^metadata_user=.\+/metadata_user=$WCPS_USER/" db/settings.properties
189sed -i "s/^metadata_pass=.\+/metadata_pass=$WCPS_PASSWORD/" db/settings.properties
190echo "ccip_hack=true" >> db/settings.properties
191su - $USER_NAME make setupdb
192make deploy CATALINA_HOME=/var/lib/tomcat6
193
194cd -
195
196cd ../
197
198#-------------------------------------------------------------------------------
199# download, extract, and import demo data into rasdaman
200wget -c --progress=dot:mega \
201 http://kahlua.eecs.jacobs-university.de/~earthlook/osgeo/rasdaman_data_8-3.tar.gz
202
203tar xzf rasdaman_data_8-3.tar.gz -C .
204
205PATH="$PATH:$RASDAMAN_HOME/bin"
206export PATH
207
208echo importing data...
209cd rasdaman_data_8-3/DataImport
210sed -i "s/\/usr\/local\/bin\/insertdemo.sh localhost 7001 \/usr\/local\/share\/rasdaman\/examples\/images rasadmin rasadmin/\/usr\/local\/rasdaman\/bin\/insertdemo.sh localhost 7001 \/usr\/local\/rasdaman\/share\/rasdaman\/examples\/images rasadmin rasadmin /g" demodata/Makefile
211sed -i "s/PATH+=\":\$(RASGEO)\/bin\"/MAP=lena/g" lena/Makefile
212
213make all
214
215
216#copy demo applications into tomcat webapps directory
217cd ../
218
219if [ ! -d "/var/lib/tomcat6/webapps/earthlook" ] ; then
220 echo moving earthlook folder into tomcat webapps...
221 mv rasdaman/* /var/lib/tomcat6/webapps/
222fi
223
224#clean up
225echo "cleaning up..."
226/etc/init.d/rpcbind start
227su - "$USER_NAME" "$RASDAMAN_HOME"/bin/stop_rasdaman.sh
228su - "$USER_NAME" "$RASDAMAN_HOME"/bin/start_rasdaman.sh
229
230pkg_cleanup
231
232# Sun's Java should already be present..
233apt-get install --assume-yes libecpg6
234
235#Don't delete the tmp files, so we can stash them in a cache
236#rm "$TMP" -rf
237
238
239#add rasdaman/earthlook to the ubuntu menu icons
240cat << EOF > /usr/share/applications/start_rasdaman_server.desktop
241[Desktop Entry]
242Type=Application
243Encoding=UTF-8
244Name=Start Rasdaman Server
245Comment=Start Rasdaman Server
246Categories=Application;Education;Geography;
247Exec=/usr/local/rasdaman/bin/start_rasdaman.sh
248Icon=gnome-globe
249Terminal=true
250StartupNotify=false
251EOF
252
253
254cat << EOF > /usr/share/applications/stop_rasdaman_server.desktop
255[Desktop Entry]
256Type=Application
257Encoding=UTF-8
258Name=Stop Rasdaman Server
259Comment=Stop Rasdaman Server
260Categories=Application;Education;Geography;
261Exec=/usr/local/rasdaman/bin/stop_rasdaman.sh
262Icon=gnome-globe
263Terminal=true
264StartupNotify=false
265EOF
266
267
268cat << EOF > /usr/share/applications/rasdaman-earthlook-demo.desktop
269[Desktop Entry]
270Type=Application
271Encoding=UTF-8
272Name=Rasdaman-Earthlook Demo
273Comment=Rasdaman Demo and Tutorial
274Categories=Application;Education;Geography;
275Exec=firefox http://localhost:8080/earthlook
276Icon=gnome-globe
277Terminal=false
278StartupNotify=false
279EOF
280
281cp /usr/share/applications/stop_rasdaman_server.desktop "$USER_HOME/Desktop/"
282cp /usr/share/applications/start_rasdaman_server.desktop "$USER_HOME/Desktop/"
283cp /usr/share/applications/rasdaman-earthlook-demo.desktop "$USER_HOME/Desktop/"
284
285
286### rasmgr.conf wants the hostname to be defined at build time, but the hostname on our
287### ISO and VM are different ('user' vs 'osgeo-live'). so we have to re-set the value
288### at boot time.
289if [ `grep -c 'rasdaman' /etc/rc.local` -eq 0 ] ; then
290 sed -i -e 's|exit 0||' /etc/rc.local
291 echo 'sed -i -e "s/ -host [^ ]*/ -host $HOSTNAME/" /usr/local/rasdaman/etc/rasmgr.conf' >> /etc/rc.local
292 echo >> /etc/rc.local
293 echo "exit 0" >> /etc/rc.local
294fi
295