forked from OSGeo/OSGeoLive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_openlayers.sh
executable file
·176 lines (155 loc) · 5.35 KB
/
install_openlayers.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
#!/bin/sh
#############################################################################
#
# Purpose: This script will OpenLayers 6 (and OpenLayers 2.13.1 for legacy
# demos in OSGeoLive)
#
#############################################################################
# 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".
#############################################################################
# Running:
# =======
# sudo service apache2 start
# Then open a web browser and go to http://localhost/ol3/
./diskspace_probe.sh "`basename $0`" begin
BUILD_DIR=`pwd`
####
if [ -z "$USER_NAME" ] ; then
USER_NAME="user"
fi
USER_HOME="/home/$USER_NAME"
TMP_DIR="/tmp/build_openlayers"
OL2_VERSION="2.13.1"
OL2_DIR=/var/www/html/ol2
OPENLAYERS_VERSION="6.14.1"
OPENLAYERS_DIR=/var/www/html/openlayers
#
# Install OpenLayers 2
#
echo "\nCreating temporary directory $TMP_DIR..."
mkdir -p "$TMP_DIR"
echo "\nCreating OpenLayers2 directory $OL2_DIR..."
mkdir -p "$OL2_DIR"
echo "\nCreating OpenLayers directory $OPENLAYERS_DIR..."
mkdir -p "$OPENLAYERS_DIR"
echo "\nDownloading OpenLayers2..."
cd "$TMP_DIR"
if [ -f "OpenLayers-$OL2_VERSION.tar.gz" ]
then
echo "OpenLayers-$OL2_VERSION.tar.gz has already been downloaded."
else
wget -c --progress=dot:mega \
"http://github.com/openlayers/ol2/releases/download/release-$OL2_VERSION/OpenLayers-$OL2_VERSION.tar.gz"
fi
echo "\nInstalling OpenLayers2..."
tar zxf "OpenLayers-$OL2_VERSION.tar.gz"
cd "OpenLayers-$OL2_VERSION"
mv OpenLayers.js "$OL2_DIR"/
mv img "$OL2_DIR"/
mv theme "$OL2_DIR"/
chmod -R uga+r "$OL2_DIR"
echo "\nCleaning up..."
cd "$TMP_DIR"
rm -rf "OpenLayers-$OL2_VERSION"
rm "OpenLayers-$OL2_VERSION.tar.gz"
#
# Install OpenLayers
#
echo "\nInstalling OpenLayers..."
cd "$TMP_DIR"
OPENLAYERS_ARCHIVE_FULL="v$OPENLAYERS_VERSION.zip"
if [ -f "$OPENLAYERS_ARCHIVE_FULL" ]
then
echo "OpenLayers $OPENLAYERS_VERSION full version has already been downloaded. Skipping download."
else
wget -c --progress=dot:mega \
"https://github.com/openlayers/openlayers/releases/download/v$OPENLAYERS_VERSION/v$OPENLAYERS_VERSION.zip"
echo "OpenLayers $OPENLAYERS_VERSION full version download complete."
fi
OPENLAYERS_ARCHIVE_DIST="v$OPENLAYERS_VERSION-dist.zip"
if [ -f "$OPENLAYERS_ARCHIVE_DIST" ]
then
echo "OpenLayers $OPENLAYERS_VERSION distribution version has already been downloaded. Skipping download."
else
wget -c --progress=dot:mega \
"https://github.com/openlayers/openlayers/releases/download/v$OPENLAYERS_VERSION/v$OPENLAYERS_VERSION-dist.zip"
echo "OpenLayers $OPENLAYERS_VERSION distribution version download complete."
fi
#
# Unzip
#
echo "\nUnzipping archive..."
unzip -qo $OPENLAYERS_ARCHIVE_FULL
unzip -qo $OPENLAYERS_ARCHIVE_DIST
echo "Unzipping done"
#
# Replace assets url and workshop url
#
sed -i 's/..\/..\/..\/assets/https:\/\/openlayers.org\/assets/g' v$OPENLAYERS_VERSION/doc/*.html
sed -i 's/..\/..\/..\/..\/assets/https:\/\/openlayers.org\/assets/g' v$OPENLAYERS_VERSION/doc/**/*.html
sed -i 's/\/workshop\//https:\/\/openlayers.org\/workshop\//g' v$OPENLAYERS_VERSION/doc/index.html
#
# Copy to www
#
echo "\nCopying files to $OPENLAYERS_DIR"
rsync -r v$OPENLAYERS_VERSION/* $OPENLAYERS_DIR
rsync -r v$OPENLAYERS_VERSION-dist/* $OPENLAYERS_DIR/dist
echo "Copying done"
#
# Generate index page
#
cd "$OPENLAYERS_DIR"
echo "\nGenerating index file..."
cat << EOF > "index.html"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<h1>OpenLayers $OPENLAYERS_VERSION</h1>
<p>Welcome to OpenLayers index page:</p>
<ul>
<li><a href="apidoc/">API Docs</a>: explore the project documentation</li>
<li><a href="examples/">Examples</a>: see the project in action</li>
<li><a href="https://openlayers.org/">OpenLayers.org website</a></li>
</ul>
</body>
</html>
EOF
echo "Index file generation done"
#
# Launch script and icon for OpenLayers to take you to a documentation
# page and examples listing
#
echo "\nGenerating launcher..."
cp "$OPENLAYERS_DIR/apidoc/logo-70x70.png" /usr/share/pixmaps/openlayers.png
if [ ! -e /usr/share/applications/openlayers.desktop ] ; then
cat << EOF > /usr/share/applications/openlayers.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=OpenLayers
Comment=Sample constructions
Categories=Application;Internet;
Exec=firefox http://localhost/openlayers/ http://localhost/osgeolive/en/quickstart/openlayers_quickstart.html
Icon=openlayers
Terminal=false
StartupNotify=false
EOF
fi
cp /usr/share/applications/openlayers.desktop "$USER_HOME/Desktop/"
chown "$USER_NAME:$USER_NAME" "$USER_HOME/Desktop/openlayers.desktop"
####
"$BUILD_DIR"/diskspace_probe.sh "`basename $0`" end