forked from OSGeo/OSGeoLive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_geoserver.sh
executable file
·334 lines (277 loc) · 11.6 KB
/
install_geoserver.sh
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
#!/bin/sh
# Copyright (c) 2009-2024 The Open Source Geospatial Foundation and others.
# Licensed under the GNU LGPL version >= 2.1.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 2.1 of the License,
# or any later version. This library is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY, without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details, either
# in the "LICENSE.LGPL.txt" file distributed with this software or at
# web page "http://www.fsf.org/licenses/lgpl.html".
#
# About:
# =====
# This script will install GeoServer in ubuntu
./diskspace_probe.sh "`basename $0`" begin
BUILD_DIR=`pwd`
####
if [ -z "$USER_NAME" ] ; then
USER_NAME="user"
fi
USER_HOME="/home/$USER_NAME"
TMP="/tmp/build_geoserver"
INSTALL_FOLDER="/usr/local/lib"
BIN="/usr/local/bin"
GS_VERSION="2.26.0"
GS_HOME="$INSTALL_FOLDER/geoserver-$GS_VERSION"
GS_PORT=8082
DOC_DIR="$GS_HOME/doc"
### Setup things... ###
## check required tools are installed
if [ ! -x "`which wget`" ] ; then
echo "ERROR: wget is required, please install it and try again"
exit 1
fi
### install_java.sh must run before this script
### TODO sanity check java setup here
### setup temp ###
mkdir -p "$TMP"
cd "$TMP"
###------------------------------------------
### Download and unpack GeoServer ###
## get GeoServer
echo "Getting GeoServer"
wget -c --progress=dot:mega \
-O geoserver-$GS_VERSION-bin.zip \
"http://download.osgeo.org/livedvd/data/geoserver/geoserver-$GS_VERSION-bin.zip"
## Cached version of
# "http://sourceforge.net/projects/geoserver/files/GeoServer/$GS_VERSION/geoserver-$GS_VERSION-bin.zip/download"
## unpack it to /usr/lib overwriting eventual existing copy
echo "Unpacking GeoServer in $GS_HOME"
mkdir -p "$GS_HOME"
unzip -o -q "geoserver-$GS_VERSION-bin.zip" -d "$GS_HOME"
## add an unversioned symlink to GeoServer home (used in quickstart)
if [ ! -e "$INSTALL_FOLDER/geoserver" ]; then
ln -s "$GS_HOME" "$INSTALL_FOLDER/geoserver"
fi
###------------------------------------------
### Configure Application ###
## We need to make sure the scripts use the proper JDK version ##
echo "Configuring GeoServer script"
sed -i "1 i # Define Java home\nJAVA_HOME=/usr/lib/jvm/default-java; export JAVA_HOME\n# Force proper GeoServer home\nGEOSERVER_HOME=$GS_HOME; export GEOSERVER_HOME\n" \
"$GS_HOME/bin/startup.sh"
sed -i "1 i # Define Java home\nJAVA_HOME=/usr/lib/jvm/default-java; export JAVA_HOME\n# Force proper GeoServer home\nGEOSERVER_HOME=$GS_HOME; export GEOSERVER_HOME\n" \
"$GS_HOME/bin/shutdown.sh"
## Make Jetty run on a different port
sed -i -e "s/8080/$GS_PORT/g" "$GS_HOME"/start.ini
## Disable logging to stdout
sed -i -e "s|<stdOutLogging>true</stdOutLogging>|<stdOutLogging>false</stdOutLogging>|g" "$GS_HOME"/data_dir/logging.xml
## Remove the pure-Java JAI and ImageIO jars bundled with GeoServer
## because they conflict with the native JAI and ImageIO
## installed at the system level by install_udig.sh
#rm -f "$GS_HOME"/webapps/geoserver/WEB-INF/lib/jai_*.jar
## Add a script that will launch the browser after starting GS
cat << EOF > "$GS_HOME/bin/start_admin.sh"
#!/bin/sh
# Writable location for GeoServer NetCDF index files
NETCDF_DATA_DIR="\$HOME/.geoserver"
mkdir -p "\$NETCDF_DATA_DIR"
export JAVA_OPTS="-DNETCDF_DATA_DIR=\$NETCDF_DATA_DIR"
$GS_HOME/bin/startup.sh &
DELAY=40
(
for TIME in \`seq \$DELAY\` ; do
sleep 1
echo "\$TIME \$DELAY" | awk '{print int(0.5+100*\$1/\$2)}'
done
) | zenity --progress --auto-close --text "GeoServer starting"
# how to set 5 sec timeout?
zenity --info --text "Starting web browser ..."
firefox "http://localhost:$GS_PORT/geoserver/web/"
EOF
## Add a script that will stop GS and notify the user graphically
cat << EOF > "$GS_HOME/bin/stop_notify.sh"
$GS_HOME/bin/shutdown.sh
zenity --info --text "GeoServer stopped"
EOF
## Make the scripts executable
chmod 755 "$GS_HOME/bin/startup.sh"
chmod 755 "$GS_HOME/bin/start_admin.sh"
chmod 755 "$GS_HOME/bin/shutdown.sh"
chmod 755 "$GS_HOME/bin/stop_notify.sh"
##
## FIXME: do not assume what's good for you is good for all other java apps
## too. If geoserver needs special Java opts, then put it in the
## start_geoserver.sh script.
#cat << EOF > /etc/profile.d/geoserver_settings.sh
#JAVA_OPTS="-DENABLE_JSONP=true -XX:MaxPermSize=128m"
#export JAVA_OPTS
#EOF
## Allow the user to write in the GeoServer data dir
adduser "$USER_NAME" users
chgrp -R users "$GS_HOME/data_dir"
chgrp -R users "$GS_HOME/logs"
chmod -R g+w "$GS_HOME/data_dir"
chmod -R g+w "$GS_HOME/logs"
## link from bin directory
if [ ! -e "$BIN/geoserver_start.sh" ] ; then
ln -s "$GS_HOME/bin/startup.sh" "$BIN/geoserver_start.sh"
fi
if [ ! -e "$BIN/geoserver_start_admin.sh" ] ; then
ln -s "$GS_HOME/bin/start_admin.sh" "$BIN/geoserver_start_admin.sh"
fi
if [ ! -e "$BIN/geoserver_stop.sh" ] ; then
ln -s "$GS_HOME/bin/shutdown.sh" "$BIN/geoserver_stop.sh"
fi
if [ ! -e "$BIN/geoserver_stop_notify.sh" ] ; then
ln -s "$GS_HOME/bin/stop_notify.sh" "$BIN/geoserver_stop_notify.sh"
fi
###------------------------------------------
### download the documentation
mkdir -p "$DOC_DIR"
echo "Getting GeoServer documentation"
wget --progress=dot:mega \
-O "geoserver-$GS_VERSION-htmldoc.zip" \
"http://download.osgeo.org/livedvd/data/geoserver/geoserver-$GS_VERSION-htmldoc.zip"
## Cached version of
# "http://sourceforge.net/projects/geoserver/files/GeoServer/$GS_VERSION/geoserver-$GS_VERSION-htmldoc.zip/download"
## unpack it
echo "Installing GeoServer documentation"
unzip -o -q "geoserver-$GS_VERSION-htmldoc.zip" -d "$DOC_DIR"
###------------------------------------------
### download and install INSPIRE extension
echo "Getting INSPIRE extension"
wget --progress=dot:mega \
-O "geoserver-$GS_VERSION-inspire-plugin.zip" \
"http://download.osgeo.org/livedvd/data/geoserver/geoserver-$GS_VERSION-inspire-plugin.zip"
## Cached version of
# "http://sourceforge.net/projects/geoserver/files/GeoServer/$GS_VERSION/extensions/geoserver-$GS_VERSION-inspire-plugin.zip/download"
echo "Installing INSPIRE extension"
unzip -o -q "geoserver-$GS_VERSION-inspire-plugin.zip" -d "$GS_HOME/webapps/geoserver/WEB-INF/lib"
###------------------------------------------
### download and install CSS extension
echo "Getting CSS extension"
wget --progress=dot:mega \
-O "geoserver-$GS_VERSION-css-plugin.zip" \
"http://download.osgeo.org/livedvd/data/geoserver/geoserver-$GS_VERSION-css-plugin.zip"
## Cached version of
# "http://sourceforge.net/projects/geoserver/files/GeoServer/$GS_VERSION/extensions/geoserver-$GS_VERSION-css-plugin.zip/download"
echo "Installing CSS extension"
unzip -o -q "geoserver-$GS_VERSION-css-plugin.zip" -d "$GS_HOME/webapps/geoserver/WEB-INF/lib"
###------------------------------------------
### download and install NetCDF extension
echo "Getting NetCDF extension"
wget --progress=dot:mega \
-O "geoserver-$GS_VERSION-netcdf-plugin.zip" \
"http://download.osgeo.org/livedvd/data/geoserver/geoserver-$GS_VERSION-netcdf-plugin.zip"
## Cached version of
# "http://sourceforge.net/projects/geoserver/files/GeoServer/$GS_VERSION/extensions/geoserver-$GS_VERSION-netcdf-plugin.zip/download"
echo "Installing NetCDF extension"
unzip -o -q "geoserver-$GS_VERSION-netcdf-plugin.zip" -d "$GS_HOME/webapps/geoserver/WEB-INF/lib"
###------------------------------------------
### download and install Vector Tiles extension
echo "Getting Vector Tiles extension"
wget --progress=dot:mega \
-O "geoserver-$GS_VERSION-vectortiles-plugin.zip" \
"http://download.osgeo.org/livedvd/data/geoserver/geoserver-$GS_VERSION-vectortiles-plugin.zip"
## Cached version of
# "http://sourceforge.net/projects/geoserver/files/GeoServer/$GS_VERSION/extensions/geoserver-$GS_VERSION-vectortiles-plugin.zip/download"
echo "Installing Vector Tiles extension"
unzip -o -q "geoserver-$GS_VERSION-vectortiles-plugin.zip" -d "$GS_HOME/webapps/geoserver/WEB-INF/lib"
###------------------------------------------
### install desktop icons ##
echo "Installing GeoServer icons"
cp -f "$USER_HOME/gisvm/app-conf/geoserver/geoserver_48x48.logo.png" \
/usr/share/icons/
## start icon
cat << EOF > /usr/share/applications/geoserver-start.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Start GeoServer
Comment=GeoServer $GS_VERSION
Categories=Application;Geography;Geoscience;Education;
Exec=$BIN/geoserver_start_admin.sh
Icon=/usr/share/icons/geoserver_48x48.logo.png
Terminal=false
EOF
cp -a /usr/share/applications/geoserver-start.desktop "$USER_HOME/Desktop/"
chown -R "$USER_NAME":"$USER_NAME" "$USER_HOME/Desktop/geoserver-start.desktop"
## stop icon
cat << EOF > /usr/share/applications/geoserver-stop.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Stop GeoServer
Comment=GeoServer $GS_VERSION
Categories=Application;Geography;Geoscience;Education;
Exec=$BIN/geoserver_stop_notify.sh
Icon=/usr/share/icons/geoserver_48x48.logo.png
Terminal=false
EOF
cp -a /usr/share/applications/geoserver-stop.desktop "$USER_HOME/Desktop/"
chown -R "$USER_NAME":"$USER_NAME" "$USER_HOME/Desktop/geoserver-stop.desktop"
## admin console icon
cat << EOF > /usr/share/applications/geoserver-admin.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Admin GeoServer
Comment=GeoServer $GS_VERSION
Categories=Application;Geography;Geoscience;Education;
Exec=firefox "http://localhost:$GS_PORT/geoserver/"
Icon=/usr/share/icons/geoserver_48x48.logo.png
Terminal=false
EOF
cp -a /usr/share/applications/geoserver-admin.desktop "$USER_HOME/Desktop/"
chown -R "$USER_NAME":"$USER_NAME" "$USER_HOME/Desktop/geoserver-admin.desktop"
## styler console icon
########## DEAD URL ###################
# fgdrf : commentet, never referenced in quickstart guide
#cat << EOF > /usr/share/applications/geoserver-styler.desktop
#[Desktop Entry]
#Type=Application
#Encoding=UTF-8
#Name=Style GeoServer
#Comment=GeoServer ${GS_VERSION} Styler Extension
#Categories=Application;Geography;Geoscience;Education;
#Exec=firefox "http://localhost:$GS_PORT/geoserver/www/styler"
#Icon=/usr/share/icons/geoserver_48x48.logo.png
#Terminal=false
#EOF
## documentation icon
cat << EOF > /usr/share/applications/geoserver-docs.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=GeoServer documentation
Comment=GeoServer $GS_VERSION Documentation
Categories=Application;Geography;Geoscience;Education;
Exec=firefox "$DOC_DIR/user/index.html"
Icon=/usr/share/icons/geoserver_48x48.logo.png
Terminal=false
EOF
cp -a /usr/share/applications/geoserver-docs.desktop "$USER_HOME/Desktop/"
chown -R "$USER_NAME":"$USER_NAME" "$USER_HOME/Desktop/geoserver-docs.desktop"
## add sample styles per quickstart
mkdir /usr/local/share/geoserver
chgrp users /usr/local/share/geoserver
chmod g+w /usr/local/share/geoserver
cp /usr/local/share/gisvm/app-data/geoserver/ne_10m*.sld \
/usr/local/share/geoserver/
## add sample data for NetCDF section of quickstart (from GeoServer 2.10.4 as removed in later versions)
mkdir -p /usr/local/share/data/netcdf
wget --progress=dot:mega \
-O /usr/local/share/data/netcdf/polyphemus_20120401.nc \
"https://github.com/geoserver/geoserver/raw/2.10.4/doc/en/user/source/rest/examples/polyphemus_20120401.nc"
## clean up eventual leftover Jetty cache directory
echo "Cleaning up Jetty JSP cache in /tmp"
rm -rf /tmp/Jetty*geoserver*
## leave single version of parboiled library in the GeoServer lib path
rm "$GS_HOME"/webapps/geoserver/WEB-INF/lib/parboiled-*-1.2.0.jar
rm "$GS_HOME"/webapps/geoserver/WEB-INF/lib/gs-web-app-*-SNAPSHOT.jar
####
"$BUILD_DIR"/diskspace_probe.sh "`basename $0`" end