forked from OSGeo/OSGeoLive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_openlayers.sh
executable file
·153 lines (138 loc) · 4.26 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
#!/bin/sh
# Copyright (c) 2009 The Open Source Geospatial Foundation.
# 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 OpenLayers 3.0.0
#
# Running:
# =======
# sudo service apache2 start
# Then open a web browser and go to http://localhost/openLayers/
./diskspace_probe.sh "`basename $0`" begin
BIN_DIR=`pwd`
####
if [ -z "$USER_NAME" ] ; then
USER_NAME="user"
fi
USER_HOME="/home/$USER_NAME"
TMP_DIR="/tmp/build_openlayers"
OL_VERSION="v3.0.0"
GIT_DIR="$TMP_DIR/openlayers-$OL_VERSION"
GIT_OL3_URL="https://github.com/openlayers/ol3.git"
BUILD_DIR="build/hosted/HEAD"
WWW_DIR=/var/www/html/openlayers
#
# Make certain of some prerequisites
#
apt-get install --yes python-pip python-pystache node npm
#
# Clone repository, checkout the latest stable tag and install dependencies
#
echo "\nCreating temporary directory $TMP_DIR..."
mkdir -p "$TMP_DIR"
cd "$TMP_DIR"
echo "\nFetching project..."
if [ ! -d "$GIT_DIR" ] ; then
# Clone project and checkout the stable tag
echo "\nClonning project from $GIT_OL3_URL..."
git clone "$GIT_OL3_URL" "$GIT_DIR"
echo "\nChanging to tag $OL_VERSION..."
cd "$GIT_DIR"
git checkout "$OL_VERSION"
# Install dependencies for build process
echo "\nInstalling npm dependencies..."
npm install
echo "\nInstalling other dependencies..."
pip install -r requirements.txt
cd -
else
echo "... OpenLayers-$OL_VERSION already cloned\n"
fi
cd "$GIT_DIR"
#
# Build OpenLayers and examples
#
echo "\nBuilding OpenLayers and examples..."
if [ ! -d "$GIT_DIR/build" ] ; then
# NOTE: The 'host-examples' also includes the 'build' target
./build.py host-examples
else
echo "... previous built for OpenLayers-$OL_VERSION exists. Remove $GIT_DIR/build to create a fresh built.\n"
fi
#
# Build API docs
#
echo "\nBuilding API docs..."
if [ ! -d "$GIT_DIR/$BUILD_DIR/apidoc" ] ; then
./build.py apidoc
else
echo "... previous version of API docs for OpenLayers-$OL_VERSION exists. Remove $GIT_DIR/build/apidocs to create a fresh built.\n"
fi
#
# Generate index page
#
cd "$GIT_DIR/$BUILD_DIR"
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>
<h2>OpenLayers $OL_VERSION</h2>
<ul>
build/hosted/HEAD/apidoc
<li><a href="build/hosted/HEAD/apidoc/">API Docs</a></li>
<li><a href="build/hosted/HEAD/examples/">Examples</a></li>
<li><a href="http://openlayers.org/">OpenLayers.org website</a></li>
</ul>
</body>
</html>
EOF
#
# Copy files to apache dir
#
mkdir -p "$WWW_DIR"
cp -R "$GIT_DIR/$BUILD_DIR" "$WWW_DIR"
chmod -R uga+r "$WWW_DIR"
#
# Launch script and icon for OpenLayers to take you to a documentation
# page and examples listing
#
cp "$GIT_DIR/$BUILD_DIR/resources/logo.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/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"
#
# Add a symbolic link into the ipython notebook extension directory
# TODO - Necessary ???
#
mkdir -p "$USER_HOME"/.ipython/nbextensions/
ln -s /var/www/html/openlayers/ "$USER_HOME"/.ipython/nbextensions/
####
"$BIN_DIR"/diskspace_probe.sh "`basename $0`" end