forked from pmalves/ctools-installer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ctools-installer.sh
executable file
·526 lines (414 loc) · 13 KB
/
ctools-installer.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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
#!/bin/bash
INSTALLER=`basename "$0"`
VER='1.25'
echo
echo CTOOLS
echo
echo ctools-installer version $VER
echo
echo "Author: Pedro Alves (webdetails)"
echo Thanks to Analytical Labs for jenkins builds
echo Copyright Webdetails 2011
echo
echo
echo Changelog:
echo
echo v1.25 - Removed overwrite, explicitly deleting marketplace definition
echo v1.24 - Added force overwrite to unzip to phase out overwrite confirmation
echo v1.23 - CDF trunk installation change due to js publish
echo v1.22 - Changed saiku download path to 2.2
echo v1.21 - Added support for CDE stable \(release\) installations.
echo v1.20 - CDF new samples location updated to stable installation.
echo v1.19 - Corrected installCDF and installCDE to remove samples dir before installing
echo v1.18 - CDA samples installation to plugin-samples also in stable mode.
echo v1.17 - Change to CDA and CDE samples installation. Now installs to folder plugin-samples instead of bi-developers \(for trunk snapshot only\).
echo v1.16 - Added support for CDC and Saiku-adhoc installation - for now only available in dev/trunk mode.
echo v1.15 - Change to CDF samples installation. Now installs to folder plugin-samples instead of bi-developers \(for trunk snapshot only\).
echo v1.14 - Added support for CDF stable \(release\) installations.
echo v1.13 - Fixed issue in CGG download
echo v1.12 - Fixed typo in -Y option
echo v1.11 - Added support for -y option \(assume yes\) - Thanks to Christian G. Warden
echo v1.10 - Added support for Saiku trunk snapshots installations.
echo v1.9 - Added support for CDA stable \(release\) installations.
echo v1.8 - Added CGG\; Script refactor
echo v1.7 - Changed url locations to new path of analytical labs
echo v1.6 - Changed saiku download path to 2.1
echo v1.5 - Changed default indicator values in prompts
echo v1.4 - Added Saiku for the list of installs
echo v1.3 - Added support for automatic updates
echo v1.2 - Silent mode for downloading
echo v1.1 - Minor bugfixes
echo v1.0 - First release
echo
echo
echo "Disclaimer: we can't be responsible for any damage done to your system, which hopefully will not happen"
echo Note: ctools-installer.sh will upgrade the plugins under system directory.
echo " Any changes you have made there (eg: cdf templates) will have to be backed up and manually copied after running the script"
echo " CGG will need to change the server WEB-INF/lib too. Backup your server"
echo
usage (){
echo
echo "Usage: ctools-installer.sh -s solutionPath [-w pentahoWebapPath] [-b branch]"
echo
echo "-s Solution path (eg: /biserver/pentaho-solutions)"
echo "-w Pentaho webapp server path (requiresd for cgg, eg: /biserver-ce/tomcat/webapps/pentaho)"
echo "-b Branch from where to get ctools, stable for release, dev for trunk. Default is stable"
echo "-y Assume yes to all prompts"
echo "-h This help screen"
echo
exit 1
}
cleanup (){
rm -rf .tmp
}
# Parse options
[ $# -gt 1 ] || usage
SOLUTION_DIR='PATH' # Variable name
WEBAPP_PATH='PATH' # Show all matches (y/n)?
HAS_WEBAPP_PATH=0
BRANCH='stable'
ASSUME_YES=false
while [ $# -gt 0 ]
do
case "$1" in
--) shift; break;;
-s) SOLUTION_DIR="$2"; shift;;
-w) WEBAPP_PATH="$2"; shift;;
-b) BRANCH="$2"; shift;;
-y) ASSUME_YES=true;;
--) break;;
-*|-h) usage ;;
esac
shift
done
[ $SOLUTION_DIR = 'PATH' ] && usage
if [ $WEBAPP_PATH != 'PATH' ]
then
HAS_WEBAPP_PATH=1
fi
if [ $BRANCH != 'stable' ] && [ $BRANCH != 'dev' ]
then
echo ERROR: Branch must either be stable or dev
exit 1
fi
if [[ ! -d $SOLUTION_DIR ]]
then
echo ERROR: Supplied solution path is not a directory
exit 1
fi
if [[ ! -d $SOLUTION_DIR/system ]]
then
echo "ERROR: Supplied solution path doesn't look like a valid pentaho solutions directory. Missing system sub-directory."
exit 1
fi
if [[ $HAS_WEBAPP_PATH -eq 1 ]]
then
if [[ ! -d $WEBAPP_PATH/WEB-INF/lib ]]
then
echo "ERROR: Supplied webapp path doesn't look like a valid web application - missing WEB-INF/lib"
exit 1
fi
fi
URL1='-release'
FILESUFIX='-??.??.??'
if [ $BRANCH = 'dev' ]
then
URL1=''
FILESUFIX='-TRUNK-SNAPSHOT'
fi
# Checking for a new version
rm -rf .tmp
mkdir -p .tmp/dist
wget --no-check-certificate 'https://raw.github.com/pmalves/ctools-installer/master/ctools-installer.sh' -P .tmp -o /dev/null
if ! diff $0 .tmp/ctools-installer.sh >/dev/null ; then
echo
echo -n "There a new ctools-installer version available. Do you want to upgrade? (y/N) "
read -e answer
case $answer in
[Yy]* ) cp .tmp/ctools-installer.sh $0; echo "Upgrade successfull. Rerun"; exit 0;;
esac
fi
# Define download functions
downloadCDF (){
# CDF
URL='http://ci.analytical-labs.com/job/Webdetails-CDF'$URL1'/lastSuccessfulBuild/artifact/bi-platform-v2-plugin/dist/*zip*/dist.zip'
echo -n "Downloading CDF... "
wget --no-check-certificate $URL -P .tmp/dist/ -o /dev/null
rm -f .tmp/dist/marketplace.xml
unzip .tmp/dist/dist.zip -d .tmp > /dev/null
echo "Done"
}
downloadCDA (){
# CDA
URL='http://ci.analytical-labs.com/job/Webdetails-CDA'$URL1'/lastSuccessfulBuild/artifact/dist/*zip*/dist.zip'
echo -n "Downloading CDA... "
wget --no-check-certificate $URL -P .tmp/cda -o /dev/null
rm -f .tmp/dist/marketplace.xml
unzip .tmp/cda/dist.zip -d .tmp > /dev/null
echo "Done"
}
downloadCDE (){
# CDE
echo -n "Downloading CDE... "
wget --no-check-certificate 'http://ci.analytical-labs.com/job/Webdetails-CDE'$URL1'/lastSuccessfulBuild/artifact/server/plugin/dist/*zip*/dist.zip' -P .tmp/cde -o /dev/null
rm -f .tmp/dist/marketplace.xml
unzip .tmp/cde/dist.zip -d .tmp > /dev/null
echo "Done"
}
downloadCGG (){
# CGG
echo -n "Downloading CGG... "
wget --no-check-certificate 'http://ci.analytical-labs.com/job/Webdetails-CGG/lastSuccessfulBuild/artifact/*zip*/archive.zip' -P .tmp/cgg -o /dev/null
rm -f .tmp/dist/marketplace.xml
unzip .tmp/cgg/archive.zip -d .tmp > /dev/null
echo "Done"
}
downloadCDC (){
# CDC
echo -n "Downloading CDC... "
wget --no-check-certificate 'http://ci.analytical-labs.com/job/Webdetails-CDC/lastSuccessfulBuild/artifact/dist/*zip*/dist.zip' -P .tmp/cdc -o /dev/null
rm -f .tmp/dist/marketplace.xml
unzip .tmp/cdc/dist.zip -d .tmp > /dev/null
echo "Done"
}
downloadSaiku (){
# SAIKU
echo -n "Downloading Saiku... "
#
#unzip .tmp/saiku/target.zip -d .tmp > /dev/null
# tamporarily switch for 2.1
if [ $BRANCH = 'dev' ]
then
wget --no-check-certificate 'http://ci.analytical-labs.com/job/saiku-plugin/lastSuccessfulBuild/artifact/saiku-bi-platform-plugin/target/*zip*/target.zip' -P .tmp/saiku -o /dev/null
rm -f .tmp/dist/marketplace.xml
unzip .tmp/saiku/target.zip -d .tmp > /dev/null
mv .tmp/target/saiku-* .tmp
else
wget --no-check-certificate 'http://analytical-labs.com/downloads/saiku-plugin-2.2.zip' -P .tmp -o /dev/null
fi
echo "Done"
}
downloadSaikuAdhoc (){
# SAIKU Adhoc
echo -n "Downloading Saiku Adhoc... "
#
#unzip .tmp/saiku/target.zip -d .tmp > /dev/null
# tamporarily switch for 2.1
if [ $BRANCH = 'dev' ]
then
wget --no-check-certificate 'http://ci.analytical-labs.com/job/saiku-adhoc-plugin/lastSuccessfulBuild/artifact/saiku-adhoc-plugin/target/*zip*/target.zip' -P .tmp/saiku-adhoc -o /dev/null
rm -f .tmp/dist/marketplace.xml
unzip .tmp/saiku-adhoc/target.zip -d .tmp > /dev/null
mv .tmp/target/saiku-adhoc-* .tmp
fi
echo "Done"
}
# Define install functions
setupSamples() {
if [ ! -d $SOLUTION_DIR/plugin-samples ]
then
mkdir $SOLUTION_DIR/plugin-samples
fi
if [ ! -f $SOLUTION_DIR/plugin-samples/index.xml ]
then
echo '<index><visible>true</visible><name>Plugin Samples</name><description>Plugin Samples</description></index>' > $SOLUTION_DIR/plugin-samples/index.xml
fi
}
installCDF (){
rm -rf $SOLUTION_DIR/system/pentaho-cdf
# Removing samples dir. First two are deprecated
rm -rf $SOLUTION_DIR/bi-developers/cdf-samples
rm -rf $SOLUTION_DIR/plugin-samples/cdf-samples
rm -rf $SOLUTION_DIR/plugin-samples/pentaho-cdf
unzip .tmp/dist/pentaho-cdf$FILESUFIX.zip -d $SOLUTION_DIR/system/ > /dev/null
setupSamples
unzip .tmp/dist/pentaho-cdf-samples$FILESUFIX*zip -d $SOLUTION_DIR/plugin-samples/ > /dev/null
}
installCDE (){
rm -rf $SOLUTION_DIR/system/pentaho-cdf-dd
# Removing samples dir. First two are deprecated
rm -rf $SOLUTION_DIR/cde_sample
rm -rf $SOLUTION_DIR/plugin-samples/cde_sample
rm -rf $SOLUTION_DIR/plugin-samples/pentaho-cdf-dd
unzip .tmp/dist/pentaho-cdf-dd$FILESUFIX*zip -d $SOLUTION_DIR/system/ > /dev/null
setupSamples
unzip .tmp/dist/pentaho-cdf-dd-solution$FILESUFIX*zip -d $SOLUTION_DIR/plugin-samples > /dev/null
}
installCDA (){
rm -rf $SOLUTION_DIR/system/cda
# Removing samples dir. First is deprecated
rm -rf $SOLUTION_DIR/bi-developers/cda
rm -rf $SOLUTION_DIR/plugin-samples/cda
unzip .tmp/dist/cda$FILESUFIX*zip -d $SOLUTION_DIR/system/ > /dev/null
setupSamples
unzip .tmp/dist/cda-samples-*zip -d $SOLUTION_DIR/plugin-samples > /dev/null
}
installCGG (){
rm -rf $SOLUTION_DIR/system/cgg
unzip .tmp/archive/dist/cgg-TRUNK-SNAP*zip -d $SOLUTION_DIR/system/ > /dev/null
# Changes to the server; 1 - delete batik; 2 - copy new one plus xml and fop
LIB_DIR=$WEBAPP_PATH/WEB-INF/lib
CGG_DIR=$SOLUTION_DIR/system/cgg/lib
rm -rf $LIB_DIR/batik-* $LIB_DIR/xml-apis* $LIB_DIR/xmlgraphics*
cp $CGG_DIR/batik-[^j]* $CGG_DIR/xml* $LIB_DIR
}
installCDC (){
rm -rf $SOLUTION_DIR/system/cdc
unzip .tmp/dist/cdc-TRUNK-SNAP*zip -d $SOLUTION_DIR/system/ > /dev/null
# Changes to the server;
# 1 - copy mondrian lib to WEB-INF
LIB_DIR=$WEBAPP_PATH/WEB-INF/lib
CDC_MONDRIAN_DIR=$SOLUTION_DIR/system/cdc/mondrian-lib
rm -rf $LIB_DIR/cdc-mondrian-*.jar
cp $CDC_MONDRIAN_DIR/*.jar $LIB_DIR
# 2 - copy hazelcast to WEB-INF/lib
CDC_HAZELCAST_DIR=$SOLUTION_DIR/system/cdc/pentaho-lib
rm -rf $LIB_DIR/hazelcast-*.jar
rm -rf $LIB_DIR/cdc-hazelcast-*.jar
cp $CDC_HAZELCAST_DIR/*.jar $LIB_DIR
}
installSaiku (){
rm -rf $SOLUTION_DIR/system/saiku
unzip .tmp/saiku-plugin*zip -d $SOLUTION_DIR/system/ > /dev/null
}
installSaikuAdhoc (){
rm -rf $SOLUTION_DIR/system/saiku-adhoc
unzip .tmp/saiku-adhoc-plugin*zip -d $SOLUTION_DIR/system/ > /dev/null
}
# read options for stuff to download/install
INSTALL_CDF=0
INSTALL_CDA=0
INSTALL_CDE=0
INSTALL_CGG=0
INSTALL_CDC=0
INSTALL_SAIKU=0
INSTALL_SAIKU_ADHOC=0
if $ASSUME_YES; then
INSTALL_CDF=1
else
echo
echo -n "Install CDF? This will delete everything in $SOLUTION_DIR/system/pentaho-cdf. you sure? (y/N) "
read -e answer
case $answer in
[Yy]* ) INSTALL_CDF=1;;
* ) ;;
esac
fi
if $ASSUME_YES; then
INSTALL_CDA=1
else
echo
echo -n "Install CDA? This will delete everything in $SOLUTION_DIR/system/cda. you sure? (y/N) "
read -e answer
case $answer in
[Yy]* ) INSTALL_CDA=1;;
* ) ;;
esac
fi
if $ASSUME_YES; then
INSTALL_CDE=1
else
echo
echo -n "Install CDE? This will delete everything in $SOLUTION_DIR/system/pentaho-cdf-dd. you sure? (y/N) "
read -e answer
case $answer in
[Yy]* ) INSTALL_CDE=1;;
* ) ;;
esac
fi
if [[ $HAS_WEBAPP_PATH -eq 1 ]]
then
if $ASSUME_YES; then
INSTALL_CGG=1
else
echo
echo -n "Install CGG? This will delete everything in $SOLUTION_DIR/system/cgg. you sure? (y/N) "
read -e answer
case $answer in
[Yy]* ) INSTALL_CGG=1;;
* ) ;;
esac
fi
else
echo
echo 'No webapp path provided, will not install CGG'
fi
#if [ $BRANCH = 'dev' ]
if false;
then
if [[ $HAS_WEBAPP_PATH -eq 1 ]]
then
if $ASSUME_YES; then
INSTALL_CDC=1
else
echo
echo -n "Install CDC? This will delete everything in $SOLUTION_DIR/system/cdc. you sure? (y/N) "
read -e answer
case $answer in
[Yy]* ) INSTALL_CDC=1;;
* ) ;;
esac
fi
else
echo
echo 'No webapp path provided, will not install CDC'
fi
fi
if $ASSUME_YES; then
INSTALL_SAIKU=1
else
echo
echo -n "Install Saiku? This will delete everything in $SOLUTION_DIR/system/saiku. you sure? (y/N) "
read -e answer
case $answer in
[Yy]* ) INSTALL_SAIKU=1;;
* ) ;;
esac
fi
if [ $BRANCH = 'dev' ]
then
if $ASSUME_YES; then
INSTALL_SAIKU_ADHOC=1
else
echo
echo -n "Install Saiku Adhoc? This will delete everything in $SOLUTION_DIR/system/saiku-adhoc. you sure? (y/N) "
read -e answer
case $answer in
[Yy]* ) INSTALL_SAIKU_ADHOC=1;;
* ) ;;
esac
fi
fi
nothingToDo (){
echo Nothing to do. Exiting
cleanup
exit 1
}
[ $INSTALL_CDF -ne 0 ] || [ $INSTALL_CDE -ne 0 ] || [ $INSTALL_CDA -ne 0 ] || [ $INSTALL_CGG -ne 0 ] || [ $INSTALL_CDC -ne 0 ] || [ $INSTALL_SAIKU -ne 0 ] || [ $INSTALL_SAIKU_ADHOC -ne 0 ] || nothingToDo
# downloading files
echo
echo Downloading files
echo
[ $INSTALL_CDF -eq 0 ] || downloadCDF
[ $INSTALL_CDA -eq 0 ] || downloadCDA
[ $INSTALL_CDE -eq 0 ] || downloadCDE
[ $INSTALL_CGG -eq 0 ] || downloadCGG
[ $INSTALL_CDC -eq 0 ] || downloadCDC
[ $INSTALL_SAIKU -eq 0 ] || downloadSaiku
[ $INSTALL_SAIKU_ADHOC -eq 0 ] || downloadSaikuAdhoc
# installing files
echo
echo Installing files
echo
[ $INSTALL_CDF -eq 0 ] || installCDF
[ $INSTALL_CDA -eq 0 ] || installCDA
[ $INSTALL_CDE -eq 0 ] || installCDE
[ $INSTALL_CGG -eq 0 ] || installCGG
[ $INSTALL_CDC -eq 0 ] || installCDC
[ $INSTALL_SAIKU -eq 0 ] || installSaiku
[ $INSTALL_SAIKU_ADHOC -eq 0 ] || installSaikuAdhoc
cleanup
echo
echo Done!
echo
exit 0