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
|
---|
26 | VERSION=8.3.0
|
---|
27 | RASDAMAN_LOCATION="http://www.rasdaman.com/Download"
|
---|
28 | RASDAMAN_TARBALL="rasdaman-$VERSION.tar.gz"
|
---|
29 |
|
---|
30 | # live disc's username is "user"
|
---|
31 | USER_NAME="user"
|
---|
32 | USER_HOME="/home/$USER_NAME"
|
---|
33 | RASDAMAN_HOME="/usr/local/rasdaman"
|
---|
34 | TMP="/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
|
---|
39 | WCPS_DATABASE="petascopedb"
|
---|
40 | WCPS_USER="petauser"
|
---|
41 | WCPS_PASSWORD="UD0b9uTt"
|
---|
42 |
|
---|
43 | mkdir -p "$TMP"
|
---|
44 | cd "$TMP"
|
---|
45 | if [ ! -d "$RASDAMAN_HOME" ]; then
|
---|
46 | mkdir "$RASDAMAN_HOME"
|
---|
47 | fi
|
---|
48 |
|
---|
49 | #get and install required packages
|
---|
50 | PACKAGES="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 |
|
---|
57 | pkg_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 |
|
---|
80 | apt-get update
|
---|
81 |
|
---|
82 | apt-key update
|
---|
83 |
|
---|
84 | apt-get install --no-install-recommends --assume-yes $PACKAGES
|
---|
85 |
|
---|
86 | if [ $? -ne 0 ] ; then
|
---|
87 | echo "ERROR: package install failed."
|
---|
88 | exit 1
|
---|
89 | fi
|
---|
90 |
|
---|
91 | # symlink from the installed libdfalt
|
---|
92 | ln -s /usr/lib/libdfalt.a /usr/lib/libdf.a
|
---|
93 | ln -s /usr/lib/libdfalt.la /usr/lib/libdf.la
|
---|
94 | ln -s /usr/lib/libdfalt.so /usr/lib/libdf.so
|
---|
95 | ln -s /usr/lib/libdfalt.so.0 /usr/lib/libdf.so.0
|
---|
96 | ln -s /usr/lib/libdfalt.so.0.0.0 /usr/lib/libdf.so.0.0.0
|
---|
97 | ln -s /usr/lib/libmfhdfalt.a /usr/lib/libmfhdf.a
|
---|
98 | ln -s /usr/lib/libmfhdfalt.la /usr/lib/libmfhdf.la
|
---|
99 | ln -s /usr/lib/libmfhdfalt.so /usr/lib/libmfhdf.so
|
---|
100 | ln -s /usr/lib/libmfhdfalt.so.0 /usr/lib/libmfhdf.so.0
|
---|
101 | ln -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 |
|
---|
106 | echo "FIXME: use a better test to avoid stale installs"
|
---|
107 |
|
---|
108 | if [ ! -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"
|
---|
112 | fi
|
---|
113 |
|
---|
114 | cd "rasdaman-$VERSION"
|
---|
115 | mkdir -p "$RASDAMAN_HOME/log"
|
---|
116 | chown "$USER_NAME" "$RASDAMAN_HOME/log/" -R
|
---|
117 |
|
---|
118 | ./configure --with-logdir="$RASDAMAN_HOME"/log \
|
---|
119 | --prefix="$RASDAMAN_HOME" --with-netcdf --with-hdf4
|
---|
120 |
|
---|
121 | if [ $? -ne 0 ] ; then
|
---|
122 | echo "ERROR: configure failed."
|
---|
123 | pkg_cleanup
|
---|
124 | exit 1
|
---|
125 | fi
|
---|
126 |
|
---|
127 | make
|
---|
128 | if [ $? -ne 0 ] ; then
|
---|
129 | echo "ERROR: compilation failed."
|
---|
130 | pkg_cleanup
|
---|
131 | exit 1
|
---|
132 | fi
|
---|
133 |
|
---|
134 | make install
|
---|
135 | if [ $? -ne 0 ] ; then
|
---|
136 | echo "ERROR: package install failed."
|
---|
137 | pkg_cleanup
|
---|
138 | exit 1
|
---|
139 | fi
|
---|
140 |
|
---|
141 | # setup rasdaview
|
---|
142 | mv "$RASDAMAN_HOME"/bin/rview "$RASDAMAN_HOME"/bin/rview.bin
|
---|
143 | cp "$RASDAMAN_HOME"/share/rasdaman/errtxts* "$RASDAMAN_HOME"/bin/
|
---|
144 | RASVIEWSCRIPT="$RASDAMAN_HOME"/bin/rasdaview
|
---|
145 | echo "#!/bin/bash" > $RASVIEWSCRIPT
|
---|
146 | echo "export RASVIEWHOME=$RASDAMAN_HOME/bin" >> $RASVIEWSCRIPT
|
---|
147 | echo "cd $RASVIEWHOME && ./rview.bin" >> $RASVIEWSCRIPT
|
---|
148 | chmod +x $RASVIEWSCRIPT
|
---|
149 |
|
---|
150 | # setup permissions
|
---|
151 | chown "$USER_NAME" "$RASDAMAN_HOME"/bin/*
|
---|
152 | chmod 774 "$RASDAMAN_HOME"/bin/*
|
---|
153 | sed -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
|
---|
157 | if [ `grep -c $RASDAMAN_HOME/rasdaman/bin $USER_HOME/.bashrc` -eq 0 ] ; then
|
---|
158 | echo 'export PATH=$PATH:'$RASDAMAN_HOME/bin >> "$USER_HOME/.bashrc"
|
---|
159 | fi
|
---|
160 |
|
---|
161 | #test if rasbase exists, if not create rasbase database
|
---|
162 | test_RASBASE=$(su - $USER_NAME -c "psql --quiet --list | grep \"RASBASE \" ")
|
---|
163 | if [ -z "$test_RASBASE" ] ; then
|
---|
164 | su - $USER_NAME $RASDAMAN_HOME/bin/create_db.sh
|
---|
165 | fi
|
---|
166 |
|
---|
167 |
|
---|
168 | # needed to start the RPC server
|
---|
169 | sed -i -e 's/OPTIONS="-w"/OPTIONS="-w -i"/' /etc/init.d/rpcbind
|
---|
170 | /etc/init.d/rpcbind restart
|
---|
171 |
|
---|
172 | su - "$USER_NAME" "$RASDAMAN_HOME"/bin/start_rasdaman.sh
|
---|
173 |
|
---|
174 | #-------------------------------------------------------------------------------
|
---|
175 | # setup petascope
|
---|
176 |
|
---|
177 | # create petascope database/user
|
---|
178 | echo creating users and metadata database
|
---|
179 | su - $USER_NAME -c "createuser $WCPS_USER --superuser"
|
---|
180 | su - $USER_NAME -c "psql template1 --quiet -c \"ALTER ROLE $WCPS_USER with PASSWORD '$WCPS_PASSWORD';\""
|
---|
181 | test_WCPSDB=$(su - $USER_NAME -c "psql --quiet --list | grep \"$WCPS_DATABASE \" ")
|
---|
182 | if [ -z "$test_WCPSDB" ] ; then
|
---|
183 | su - "$USER_NAME" -c "createdb -T template0 $WCPS_DATABASE"
|
---|
184 | fi
|
---|
185 |
|
---|
186 | cd applications/petascope
|
---|
187 | cp src/main/resources/settings.properties db
|
---|
188 | sed -i "s/^metadata_user=.\+/metadata_user=$WCPS_USER/" db/settings.properties
|
---|
189 | sed -i "s/^metadata_pass=.\+/metadata_pass=$WCPS_PASSWORD/" db/settings.properties
|
---|
190 | echo "ccip_hack=true" >> db/settings.properties
|
---|
191 | su - $USER_NAME make setupdb
|
---|
192 | make deploy CATALINA_HOME=/var/lib/tomcat6
|
---|
193 |
|
---|
194 | cd -
|
---|
195 |
|
---|
196 | cd ../
|
---|
197 |
|
---|
198 | #-------------------------------------------------------------------------------
|
---|
199 | # download, extract, and import demo data into rasdaman
|
---|
200 | wget -c --progress=dot:mega \
|
---|
201 | http://kahlua.eecs.jacobs-university.de/~earthlook/osgeo/rasdaman_data_8-3.tar.gz
|
---|
202 |
|
---|
203 | tar xzf rasdaman_data_8-3.tar.gz -C .
|
---|
204 |
|
---|
205 | PATH="$PATH:$RASDAMAN_HOME/bin"
|
---|
206 | export PATH
|
---|
207 |
|
---|
208 | echo importing data...
|
---|
209 | cd rasdaman_data_8-3/DataImport
|
---|
210 | sed -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
|
---|
211 | sed -i "s/PATH+=\":\$(RASGEO)\/bin\"/MAP=lena/g" lena/Makefile
|
---|
212 |
|
---|
213 | make all
|
---|
214 |
|
---|
215 |
|
---|
216 | #copy demo applications into tomcat webapps directory
|
---|
217 | cd ../
|
---|
218 |
|
---|
219 | if [ ! -d "/var/lib/tomcat6/webapps/earthlook" ] ; then
|
---|
220 | echo moving earthlook folder into tomcat webapps...
|
---|
221 | mv rasdaman/* /var/lib/tomcat6/webapps/
|
---|
222 | fi
|
---|
223 |
|
---|
224 | #clean up
|
---|
225 | echo "cleaning up..."
|
---|
226 | /etc/init.d/rpcbind start
|
---|
227 | su - "$USER_NAME" "$RASDAMAN_HOME"/bin/stop_rasdaman.sh
|
---|
228 | su - "$USER_NAME" "$RASDAMAN_HOME"/bin/start_rasdaman.sh
|
---|
229 |
|
---|
230 | pkg_cleanup
|
---|
231 |
|
---|
232 | # Sun's Java should already be present..
|
---|
233 | apt-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
|
---|
240 | cat << EOF > /usr/share/applications/start_rasdaman_server.desktop
|
---|
241 | [Desktop Entry]
|
---|
242 | Type=Application
|
---|
243 | Encoding=UTF-8
|
---|
244 | Name=Start Rasdaman Server
|
---|
245 | Comment=Start Rasdaman Server
|
---|
246 | Categories=Application;Education;Geography;
|
---|
247 | Exec=/usr/local/rasdaman/bin/start_rasdaman.sh
|
---|
248 | Icon=gnome-globe
|
---|
249 | Terminal=true
|
---|
250 | StartupNotify=false
|
---|
251 | EOF
|
---|
252 |
|
---|
253 |
|
---|
254 | cat << EOF > /usr/share/applications/stop_rasdaman_server.desktop
|
---|
255 | [Desktop Entry]
|
---|
256 | Type=Application
|
---|
257 | Encoding=UTF-8
|
---|
258 | Name=Stop Rasdaman Server
|
---|
259 | Comment=Stop Rasdaman Server
|
---|
260 | Categories=Application;Education;Geography;
|
---|
261 | Exec=/usr/local/rasdaman/bin/stop_rasdaman.sh
|
---|
262 | Icon=gnome-globe
|
---|
263 | Terminal=true
|
---|
264 | StartupNotify=false
|
---|
265 | EOF
|
---|
266 |
|
---|
267 |
|
---|
268 | cat << EOF > /usr/share/applications/rasdaman-earthlook-demo.desktop
|
---|
269 | [Desktop Entry]
|
---|
270 | Type=Application
|
---|
271 | Encoding=UTF-8
|
---|
272 | Name=Rasdaman-Earthlook Demo
|
---|
273 | Comment=Rasdaman Demo and Tutorial
|
---|
274 | Categories=Application;Education;Geography;
|
---|
275 | Exec=firefox http://localhost:8080/earthlook
|
---|
276 | Icon=gnome-globe
|
---|
277 | Terminal=false
|
---|
278 | StartupNotify=false
|
---|
279 | EOF
|
---|
280 |
|
---|
281 | cp /usr/share/applications/stop_rasdaman_server.desktop "$USER_HOME/Desktop/"
|
---|
282 | cp /usr/share/applications/start_rasdaman_server.desktop "$USER_HOME/Desktop/"
|
---|
283 | cp /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.
|
---|
289 | if [ `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
|
---|
294 | fi
|
---|
295 |
|
---|