-
Notifications
You must be signed in to change notification settings - Fork 6
/
cybergis-script-env.sh
executable file
·388 lines (366 loc) · 12.3 KB
/
cybergis-script-env.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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
#!/bin/bash
#This script is a work in development and is stable,
#but may change to stay up to date with other projects.
#This script requires curl and git to be installed
#Run this script using root's login shell under: sudo su -
DATE=$(date)
ENV=$1
CMD=$2
#==================================#
geonode(){
echo "geonode"
if [ $# -ne 2 ] && [ $# -ne 4 ]; then
echo "Usage: cybergis-script-env.sh geonode [install|reset]"
else
ENV=$1
CMD=$2
#
if [[ "$CMD" = "install" ]]; then
#
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh geonode install"
else
bash --login -c "geonode_install"
fi
#
elif [[ "$CMD" = "reset" ]]; then
#
source ~/.bash_aliases
workon geonode
source ~/.venvs/geonode/bin/activate
#
cd ~/geonode
paver stop
#paver reset
paver reset_hard
if [[ $# -ne 4 ]]; then
paver setup
else
paver setup --geoserver "${3}" --jetty "${4}"
fi
paver start -b 0.0.0.0:8000
#
else
echo "Usage: cybergis-script-env.sh geonode [install|reset]"
fi
fi
}
rogue(){
echo "rogue"
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh rogue [install|reset]"
else
ENV=$1
CMD=$2
#
if [[ "$CMD" = "install" ]]; then
#
bash --login -c "geonode_install"
#===============#
#Install ROGUE Components
source ~/.bash_aliases
mkvirtualenv rogue_geonode
workon rogue_geonode
#
elif [[ "$CMD" = "reset" ]]; then
#
source ~/.bash_aliases
workon rogue_geonode
#
cd ~/rogue_geonode
paver stop
paver reset
#paver reset_hard
paver build_geoserver
if [[ $# -ne 3 ]]; then
paver setup
else
paver setup --geoserver ${3}
fi
paver start -b 0.0.0.0:8000
#
else
echo "Usage: cybergis-script-env.sh geonode [install|reset]"
fi
fi
}
geonode_install(){
echo "geonode_install"
sudo apt-get update
# Add UbuntuGIS Repository to get latest GDAL package
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
# Add respository for static development
sudo add-apt-repository -y ppa:chris-lea/node.js
#
sudo apt-get update
# Essential build tools and libraries
sudo apt-get install -y build-essential libxml2-dev libxslt1-dev libjpeg-dev gettext git python-dev python-pip python-virtualenv
sudo apt-get install -y libgdal1h libgdal-dev python-gdal
sudo apt-get install -y libgeos-dev libpq-dev
# Python and Django dependencies with official packages
sudo apt-get install -y python-lxml python-psycopg2 python-django python-bs4 python-multipartposthandler transifex-client python-nose python-django-nose python-django-pagination python-django-extensions python-httplib2
# Java dependencies
sudo apt-get install -y --force-yes openjdk-6-jdk ant maven2 --no-install-recommends
#
sudo apt-get install -y nodejs
sudo npm install -y -g bower
sudo npm install -y -g grunt-cli
#
#Install python packages for development
sudo pip install virtualenvwrapper paver
#Add all these lines to ~/.bash_aliases
echo 'export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python' >> ~/.bash_aliases
echo 'export WORKON_HOME=~/.venvs' >> ~/.bash_aliases
echo 'source /usr/local/bin/virtualenvwrapper.sh'>> ~/.bash_aliases
echo 'export PIP_DOWNLOAD_CACHE=$HOME/.pip-downloads' >> ~/.bash_aliases
#echo 'workon geonode' >> ~/.bash_aliases
#===============#
#Create GeoNode Virtual Environment
source ~/.bash_aliases
mkvirtualenv geonode
workon geonode
#===============#
#Install Django Dependencies
pip install pillow
pip install pinax-theme-bootstrap==3.0a11 pinax-theme-bootstrap-account==1.0b2
pip install django-tastypie django-autocomplete-light django-mptt
pip install django-taggit django-taggit-templatetags django-modeltranslation
pip install django-jsonfield django-downloadview django-pagination django-friendly-tag-loader django-extensions
pip install django-geoexplorer django-leaflet
#
#===============#
#Install GDAL
pip install --no-install GDAL==1.10.0
cd ~/.venvs/geonode/build/GDAL
sed -i "s/\.\.\/\.\.\/apps\/gdal-config/\/usr\/bin\/gdal-config/g" setup.cfg
python setup.py build_ext --include-dirs=/usr/include/gdal
pip install --no-download GDAL==1.10.0
#===============#
#Install GeoNode
cd ~
pip install -e geonode
#
#cd ~/geonode
}
maploom(){
echo "maploom"
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh maploom [install|reset]"
else
ENV=$1
CMD=$2
if [[ "$CMD" = "install" ]]; then
sudo apt-get update
#
sudo apt-get install -y python-software-properties
#sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-add-repository ppa:chris-lea/node.js-legacy
#
sudo apt-get update
#
sudo apt-get install -y curl vim git
#For compiling nodejs, version 8.22
sudo apt-get install -y make gcc
#
#sudo apt-get install -y nodejs nodejs-dev npm
#Need old version of NodeJS for dev and npm.
#See: http://stackoverflow.com/questions/16898001/installing-a-specific-node-version-in-ubuntu
#See: https://launchpad.net/~chris-lea/+archive/ubuntu/node.js-legacy
#See: https://groups.google.com/forum/#!topic/nodejs/9HjStFy2ohY
sudo apt-get install nodejs=0.8.28-1chl1~precise1
sudo apt-get install -y nodejs-dev npm
sudo apt-get install -y npm
sudo npm config set registry http://registry.npmjs.org/
#
#sudo npm -g install grunt-cli karma bower
sudo npm -g install grunt-cli bower
#
cd ~/MapLoom
npm install grunt-karma@0.9.x wordwrap
sudo npm install
bower install
grunt watch
#
elif [[ "$CMD" = "reset" ]]; then
#
echo "reset"
#
else
echo "Usage: cybergis-script-env.sh maploom [install|reset]"
fi
fi
}
geogig(){
echo "geogig"
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh geogig [install|reset]"
echo "Requires: unzip"
else
ENV=$1
CMD=$2
if [[ "$CMD" = "install" ]]; then
sudo apt-get update
#
sudo apt-get install -y openjdk-7-jdk
#Download Builds
mkdir ~/ws
mkdir ~/ws/build
cd ~/ws/build
wget http://sourceforge.net/projects/geoserver/files/GeoServer/2.6-RC1/geoserver-2.6-RC1-bin.zip
wget https://s3.amazonaws.com/hiu-build/geogig-cli-app-1.0-SNAPSHOT.zip
wget https://s3.amazonaws.com/hiu-build/gs-geogig-2.6-SNAPSHOT-shaded-plugin.jar
#
cd /opt
sudo git clone https://github.com/state-hiu/cybergis-osm-mappings.git cybergis-osm-mappings.git
sudo git clone https://github.com/state-hiu/cybergis-styles.git cybergis-styles.git
sudo git clone https://github.com/state-hiu/cybergis-client-examples.git cybergis-client-examples.git
sudo git clone https://github.com/state-hiu/cybergis-osm-extractions.git cybergis-osm-extractions.git
#Install GeoGig Cli
sudo mkdir /opt/geogig
sudo unzip ~/ws/build/geogig-cli-app-1.0-SNAPSHOT.zip -d /opt/geogig
sudo cp /opt/cybergis-scripts.git/profile/geogig.sh /etc/profile.d/
#Install GeoServer
mkdir ~/ws/gs
unzip ~/ws/build/geoserver-2.6-RC1-bin.zip -d ~/ws/gs
cp ~/ws/build/gs-geogig-2.6-SNAPSHOT-shaded-plugin.jar ~/ws/gs/geoserver-2.6-RC1/webapps/geoserver/WEB-INF/lib/
#Make folder to store GeoGig Repositories
mkdir ~/ws/geogig
mkdir ~/ws/geogig/repo
elif [[ "$CMD" = "clear" ]]; then
#
echo "clear"
rm -fr ~/ws
rm -fr ~/etc/profile.d/geogig.sh
sudo rm -fr /opt/geogig
#
else
echo "Usage: cybergis-script-env.sh geogig [install|clear]"
fi
fi
}
ittc(){
echo "ittc"
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh ittc [install|reset]"
else
ENV=$1
CMD=$2
#
if [[ "$CMD" = "install" ]]; then
#
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
#
sudo apt-get update
#
sudo apt-get install -y curl vim git nginx
sudo apt-get install -y memcached zlib1g-dev libjpeg-dev rabbitmq-server
sudo apt-get install -y libapache2-mod-python python-dev python-pip
sudo apt-get install -y supervisor
sudo apt-get install -y mongodb-org
#
cd ~/ittc
sudo pip install -r requirements.txt
# For some reason celery doesn't install these properly.
sudo pip install https://github.com/celery/py-amqp/zipball/master
sudo pip install https://github.com/celery/billiard/zipball/master
sudo pip install https://github.com/celery/kombu/zipball/master
#Pin Current Version of MongoDB
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
#sudo apt-get install postgresql-client-common postgresql-client-9.1
#sudo apt-get install -y libgeos-dev libproj-dev
#sudo apt-get install -y gdal-bin python-gdal python-numpy
#
cd ~/ittc
sudo mkdir -p /var/www/ittc/static
sudo python manage.py collectstatic
#
elif [[ "$CMD" = "reset" ]]; then
#
echo "reset"
#
sudo rabbitmqctl stop_app
sudo rabbitmqctl reset
sudo rabbitmqctl start_app
# This will kill all currently running memcached processes, including any defaults out of /etc
sudo killall memcached
#
memcached -vv -m 128 -p 11211 -d
memcached -vv -m 1024 -p 11212 -d
memcached -vv -m 128 -p 11213 -d
#
sudo service mongod restart
#
#sudo killall supervisord
#supervisord -c supervisord.conf
#supervisorctl -c supervisord.conf stop memcached-1
#supervisorctl -c supervisord.conf stop memcached-2
#supervisorctl -c supervisord.conf stop memcached-3
#supervisorctl -c supervisord.conf stop celery
#supervisorctl -c supervisord.conf stop gunicorn
#supervisorctl -c supervisord.conf start memcached-1
#supervisorctl -c supervisord.conf start memcached-2
#supervisorctl -c supervisord.conf start memcached-3
#supervisorctl -c supervisord.conf start celery
#supervisorctl -c supervisord.conf start gunicorn
else
echo "Usage: cybergis-script-env.sh ittc [install|reset]"
fi
fi
}
if [[ "$ENV" = "geonode" ]]; then
if [ $# -ne 2 ] && [ $# -ne 4 ]; then
echo "Usage: cybergis-script-env.sh geonode [install|reset]"
echo "or"
echo "Usage: cybergis-script-env.sh geonode reset geoserver_url jetty_url"
echo "GeoServer and Jetty urls can be remote or local file (file:///.../...)"
else
export -f geonode_install
export -f geonode
if [[ "$CMD" = "install" ]]; then
bash --login -c "geonode $ENV $CMD"
elif [[ "$CMD" = "reset" ]]; then
if [[ $# -eq 2 ]]; then
bash --login -c "geonode $ENV $CMD"
else
bash --login -c "geonode $ENV $CMD '${3}' '${4}'"
fi
fi
fi
elif [[ "$ENV" = "rogue" ]]; then
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh rogue [install|reset]"
else
export -f geonode_install
export -f rogue
bash --login -c "rogue $ENV $CMD"
fi
elif [[ "$ENV" = "maploom" ]]; then
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh maploom [install|reset]"
else
export -f maploom
bash --login -c "maploom $ENV $CMD"
fi
elif [[ "$ENV" = "ittc" ]]; then
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh ittc [install|reset]"
else
export -f ittc
bash --login -c "ittc $ENV $CMD"
fi
elif [[ "$ENV" = "geogig" ]]; then
if [[ $# -ne 2 ]]; then
echo "Usage: cybergis-script-env.sh geogig [install|reset]"
else
export -f geogig
bash --login -c "geogig $ENV $CMD"
fi
else
echo "Usage: cybergis-script-env.sh [geonode|rogue|maploom|geogig|ittc]"
fi