-
Notifications
You must be signed in to change notification settings - Fork 5
/
installDeployROpen.sh
612 lines (550 loc) · 18.2 KB
/
installDeployROpen.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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
#!/bin/bash
EDITION=community
RETVAL=0
NOASK="false"
DEBUG_LOGS="false"
NOLICENSE="false"
NODE=0
DATABASE_SERVER_NAME="localhost"
DATABASE_PORT="8003"
REMOTE_DATA_BASE=local
INSTALL_FOLDER=""
ERROR_OK=0
SILENT_MODE=0
IP=""
REDHAT_VERSION=64
RSERVE_VERSION=7.4.2
VERSION=8.0
MINOR_VERSION=0
REVO_VERSION=8.0.0
REVO_BIN_STRING=Revo-$VERSION
R_VERSION=R-3.1.2
LINUX_VERSION=5
TOMCAT_VERSION=7.0.64
TOMCAT_SSL_PORT=8001
TOMCAT_PORT=8000
TOMCAT_SHUTDOWN_PORT=8002
RSERVE_PORT=8004
RSERVE_CANCEL_PORT=8005
USER=`whoami`
GROUP=`id -g -n $USER`
IS_ROOT=0
R=1
RBIN="/usr/bin/R"
R_HOME=/usr/lib64/R
LINUX=redhat
DB_PATH=""
##HOST_NAME=`/sbin/ifconfig | grep --max-count=1 'inet'| grep --max-count=1 -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
##HOST_NAME=`/sbin/ifconfig | grep --max-count=1 'inet'| grep --max-count=1 -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
HOST_NAME=localhost
checkRoot() {
uid=`id -u`
if [ 0 -eq $uid ] ; then
IS_ROOT=1
USER=apache
GROUP=apache
grepout=`grep -i "^apache" /etc/passwd`
if [ 0 -eq ${#grepout} ] ; then
useradd apache >>/dev/null 2>&1
usermod -s /sbin/nologin apache >> $PWDD/install_log.txt 2>&1
fi
grepout=`grep -i "^apache" /etc/group`
if [ 0 -eq ${#grepout} ] ; then
groupadd apache >>/dev/null 2>&1
fi
INSTALL_FOLDER=/opt/deployr/$VERSION.$MINOR_VERSION
else
IS_ROOT=0
INSTALL_FOLDER=$HOME/deployr/$VERSION.$MINOR_VERSION
fi
}
start() {
# check arguments
for var in "$@"
do
# check for unattended install
if [ "--no-ask" = $var ] ; then
NOASK="true"
elif [ "--debuglogs" = $var ] ; then
DEBUG_LOGS="true"
elif [ "--nolicense" = $var ] ; then
NOLICENSE="true"
fi
done
if [ $NOASK = "true" ] ; then
checkRelease
checkRoot
checkPrerequisites
mkdir -p $INSTALL_FOLDER
getMongodbpath
installServer
else
if [ $NOLICENSE = "false" ] ; then
confirmLicense
fi
checkRelease
checkRoot
getInstallOption
fi
}
installServer() {
configureRserve
installMongo
installTomcat
configureDeployrServer
installShellScripts
exitCode=$?
exitProgram $exitCode
}
installDatabase() {
installMongo
exitCode=$?
exitProgram $exitCode
}
checkRelease() {
if [ -e /etc/redhat-release ]; then
rel=`cat /etc/redhat-release`
x=${rel#*release}
major=${x:1:1}
LINUX_VERSION=RHEL$major
minor=${x:3:2}
REDHAT_VERSION=$major$minor
if [ $major -eq 5 ]; then
if [ $minor -lt 4 ]; then
releaseError
fi
else
if [ $major -lt 5 ]; then
releaseError
fi
fi
elif [ -e /etc/SuSE-release ]; then
rel=`cat /etc/SuSE-release`
grepout=`echo $rel | grep -c openSUSE`
if [ 1 -eq ${#grepout} ] ; then
LINUX=sles
else
x=${rel#*VERSION}
major=${x:3:2}
LINUX_VERSION=SLES$major
minor=${x:19:1}
if [ $major -eq 11 ]; then
if [ $minor -lt 2 ]; then
SLESreleaseError
fi
else
SLESreleaseError
fi
LINUX=sles
fi
else
LINUX=ubuntu
fi
}
checkPrerequisites() {
analyzeJava
if [ $? != 0 ] ; then
exitWithError -1
fi
analyzeR open $NOASK
if [ $? != 0 ] ; then
exitWithError -1
fi
analyzeRserve $PWDD/installFiles/rserve
if [ $? != 0 ] ; then
exitWithError -1
fi
}
checkPrerequisitesForNode() {
analyzeR
if [ $? != 0 ] ; then
exitWithError -1
fi
analyzeRserve $PWDD/installFiles/rserve
if [ $? != 0 ] ; then
exitWithError -1
fi
}
releaseError() {
printAttentionMsg "version 5.4 or greater is required to install this software "
echo "version 5.4 or greater is required to install this software " >> $PWDD/install_log.txt 2>&1
exitWithError -1
}
SLESreleaseError() {
printAttentionMsg "version 11.2 or greater is required to install this software "
echo "version 11.2 or greater is required to install this software " >> $PWDD/install_log.txt 2>&1
exitWithError -1
}
exitProgram() {
exit $1
}
out() {
if [ -n "$OUTPUT_FILE" ] ; then
printf "%s\n" "$@" >> "$OUTPUT_FILE"
elif [ 0 -eq $SILENT_MODE ] ; then
printf "%s\n" "$@"
fi
}
installShellScripts() {
cd $PWDD/installFiles
tools/installShellScripts.sh $PWDD $INSTALL_FOLDER $REMOTE_DATA_BASE $NODE
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
echo "Error in installShellScripts" | tee -a $PWDD/install_log.txt 2>&1
exitWithError $RETVAL
fi
echo "Startup/Shutdown shell scripts installed" >> $PWDD/install_log.txt 2>&1
}
installMongo() {
cd $PWDD/installFiles
mongo/install.sh $LINUX $PWDD $INSTALL_FOLDER $DB_PATH $USER $GROUP $HOST_NAME $DATABASE_SERVER_NAME $REMOTE_DATA_BASE $TOMCAT_PORT $DATABASE_PORT $IS_ROOT
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
echo "Error in installMongo" | tee -a $PWDD/install_log.txt 2>&1
exitWithError $RETVAL
fi
echo "Mongo installed" >> $PWDD/install_log.txt 2>&1
}
configureRserve() {
cd $PWDD/installFiles
rserve/configure.sh $LINUX $PWDD $INSTALL_FOLDER $USER $GROUP $RRE_PATH $RSERVE_PATH $IS_ROOT $RSERVE_VERSION
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
exitWithError $RETVAL
fi
echo "Rserve installed" >> $PWDD/install_log.txt 2>&1
}
installTomcat() {
cd $PWDD/installFiles
tomcat/install.sh $LINUX $PWDD $INSTALL_FOLDER $TOMCAT_PORT $TOMCAT_SSL_PORT $TOMCAT_SHUTDOWN_PORT $IS_ROOT $USER $EDITION
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
echo "Error in installTomcat"
exitWithError $RETVAL
fi
echo "tomcat configured" >> $PWDD/install_log.txt 2>&1
}
configureDeployrServer() {
cd $PWDD/installFiles
config/configure.sh $PWDD $INSTALL_FOLDER $RBIN $NODE $REMOTE_DATA_BASE $DATABASE_SERVER_NAME $DEBUG_LOGS $EDITION $IS_ROOT $HOST_NAME
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
echo "Error in configureDeployrServer"
exitWithError $RETVAL
fi
echo "DeployR server configured" >> $PWDD/install_log.txt 2>&1
}
installDeployrDatabase() {
## mkdir $INSTALL_FOLDER/deployr/database >> $PWDD/install_log.txt 2>&1
if [ $IS_ROOT -eq 1 ] ; then
chown -R $USER.$GROUP $INSTALL_FOLDER
chmod -R 775 $INSTALL_FOLDER
fi
# start mongo database
$INSTALL_FOLDER/mongo/mongod.sh start >> $PWDD/install_log.txt 2>&1
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
echo "Error in starting Mongo" | tee -a $PWDD/install_log.txt 2>&1
exitWithError $RETVAL
fi
sleep 5
$PWDD/installFiles/installDeployrTables.sh $PWDD $INSTALL_FOLDER $PWDD/install_log.txt
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
echo "Error in installDeployrTables" | tee -a $PWDD/install_log.txt 2>&1
exitWithError $RETVAL
fi
echo "MongoDB database configured" | tee -a $PWDD/install_log.txt 2>&1
}
#restart() {
# out "Now starting Rserve and Tomcat. Please wait as this may take a moment." | tee -a $PWDD/install_log.txt 2>&1
# $INSTALL_FOLDER/tomcat/tomcat7.sh start >> $PWDD/install_log.txt 2>&1
# cd $INSTALL_FOLDER
# $INSTALL_FOLDER/rserve/rserve.sh start >> $PWDD/install_log.txt 2>&1
# printURL
#}
restartNode() {
out "Now restarting Rserve. Please wait as this may take a moment." | tee -a $PWDD/install_log.txt 2>&1
$INSTALL_FOLDER/rserve/rserve.sh restart >> $PWDD/install_log.txt 2>&1
}
acknowledgeInuts() {
echo "**********************************************************************"
echo "*"
echo "* DEPLOYR INSTALLATION/CONFIGURATION CONFIRMATION"
echo "*"
echo "*"
echo "* DeployR will be installed using the following paths and ports:"
echo "*"
echo "* Install DeployR under: $INSTALL_FOLDER"
echo "*"
echo "* MongoDB data folder: $DB_PATH"
echo "*"
echo "* Port specified for Tomcat: $TOMCAT_PORT"
echo "*"
echo "*"
echo "* Proceed with installation? y or n"
echo "*"
echo "**********************************************************************"
read ans
if [[ ! $ans =~ ^[Yy]$ ]] ; then
echo "installation terminated"
rm -rf $INSTALL_FOLDER >> $PWDD/install_log.txt 2>&1
exit 0
fi
}
printURL() {
echo "**********************************************************************" | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "* The installation is complete." | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "* If you are using the IPTABLES firewall, use the iptables command" | tee -a $PWDD/install_log.txt 2>&1
echo "* to open the ports listed in the 'Configuring DeployR' section of" | tee -a $PWDD/install_log.txt 2>&1
echo "* installation documentation." | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "* Open the following URL in your browser to access DeployR's landing page:" | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "* http://$HOST_NAME:$TOMCAT_PORT/deployr/landing" | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "* Please log in as 'admin'. For your security, you must set a new password for that account." | tee -a $PWDD/install_log.txt 2>&1
echo "* Note: The default password for the 'admin' and 'testuser' accounts is 'changeme'." | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "* From there, you can access:" | tee -a $PWDD/install_log.txt 2>&1
echo "* - DeployR Administration Console" | tee -a $PWDD/install_log.txt 2>&1
echo "* - DeployR Repository Manager" | tee -a $PWDD/install_log.txt 2>&1
echo "* - Product Documentation" | tee -a $PWDD/install_log.txt 2>&1
echo "* - Server status information and Diagnostic tools" | tee -a $PWDD/install_log.txt 2>&1
echo "* - DeployR API Explorer" | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "* For DeployR on an AWS EC2 instance, run $INSTALL_FOLDER/deployr/tools/setWebContext.sh -aws" | tee -a $PWDD/install_log.txt 2>&1
echo "* to set the server web context to your external IP for AWS. Until you do so, you will not" | tee -a $PWDD/install_log.txt 2>&1
echo "* be able to access the DeployR landing page or other components." | tee -a $PWDD/install_log.txt 2>&1
echo "*" | tee -a $PWDD/install_log.txt 2>&1
echo "**********************************************************************" | tee -a $PWDD/install_log.txt 2>&1
}
printAttentionMsg() {
echo "**********************************************************************"
echo "*"
echo "*"
echo "* $@"
echo "*"
echo "*"
echo "**********************************************************************"
}
printKeystoreMsg() {
echo "**********************************************************************"
echo "*"
echo "*"
echo "* A certificate is needed to secure the server."
echo "* If you have a registered certificate (recommended),"
echo "* do *not* create a temporary one now."
echo "* If you do not create a temporary certificate now, you"
echo "* will be prompted for the location of your certificate."
echo "*"
echo "* Create temporary keystore ? (y or n)"
echo "*"
echo "*"
echo "**********************************************************************"
}
printInstallMsg() {
echo "**********************************************************************"
echo "*"
echo "* Install DeployR ${VERSION}.${MINOR_VERSION} Server Options"
echo "*"
echo "* 1. Install DeployR ${VERSION}.${MINOR_VERSION} Server & Database Server (single host)"
echo "* 2. Exit installation"
echo "*"
echo "*"
echo "* Please Select Option. (1, 2)"
echo "*"
echo "**********************************************************************"
}
doInstallOptionOneorThree() {
checkPrerequisites
getInstallDirectory
getMongodbpath
getTomcatPort
acknowledgeInuts
installServer
}
getInstallOption() {
while [ 1 ]
do
printInstallMsg
read ans
if [ "1" = $ans ] ; then
doInstallOptionOneorThree
break
elif [ "2" = $ans ] ; then
exitProgram 1
else
echo "Illegal input, Please enter 1, 2"
continue
fi
done
}
getInstallDirectory() {
printAttentionMsg "Please enter the folder name where DeployR ${VERSION}.${MINOR_VERSION} will be installed"
echo " "
echo "Hit return for default folder = ${INSTALL_FOLDER}"
while [ 1 ]
do
read ans
if [ -z "${ans}" ] ; then
break
fi
echo "Is this the correct folder ? ${ans}"
echo "Enter y or n"
read ans2
if [[ $ans2 =~ ^[Yy]$ ]] ; then
INSTALL_FOLDER=$ans
break
else
echo "Please re-enter folder name"
continue
fi
done
if [ ! -e $INSTALL_FOLDER ];
then
mkdir -p $INSTALL_FOLDER >> $PWDD/install_log.txt 2>&1
if [ $? -ne 0 ]
then
printAttentionMsg "Unable to create ${INSTALL_FOLDER}"
echo "Unable to create ${INSTALL_FOLDER}" >> $PWDD/install_log.txt 2>&1
exit -1
fi
# check for write permissions
touch $INSTALL_FOLDER/deployr_temp >> $PWDD/install_log.txt 2>&1
if [ $? -ne 0 ]
then
printAttentionMsg "You do not have write permissions in ${INSTALL_FOLDER}"
exho "You do not have write permissions in ${INSTALL_FOLDER}" >> $PWDD/install_log.txt 2>&1
exit -1
else
rm -f $INSTALL_FOLDER/deployr_temp >> $PWDD/install_log.txt 2>&1
fi
else
echo "DeployR installed at $INSTALL_FOLDER. Please un-install before re-installing" | tee -a $PWDD/install_log.txt 2>&1
exit -1
fi
## get full path in case it's a relative path
INSTALL_FOLDER=`cd "$INSTALL_FOLDER"; pwd`
}
getUser() {
printAttentionMsg "Please enter the user name."
while [ 1 ]
do
read ans
echo "Is this the correct user ? ${ans}"
echo "Enter y or n"
read ans2
if [[ $ans2 =~ ^[Yy]$ ]] ; then
user=$ans
group=$ans2
break
else
echo "Please re-enter user name."
continue
fi
done
}
getTomcatPort() {
printAttentionMsg "Please enter the port for Tomcat. Hit return for default port = ${TOMCAT_PORT}"
while [ 1 ]
do
read ans
if [ -z "${ans}" ] ; then
break
fi
echo "Is this the correct port ? ${ans}"
echo "Enter y or n"
read ans2
if [[ $ans2 =~ ^[Yy]$ ]] ; then
TOMCAT_PORT=$ans
if [ $TOMCAT_PORT -eq $TOMCAT_PORT 2> /dev/null ]; then
break
else
echo "Port must be an integer. Please re-enter Tomcat port"
continue
fi
else
echo "Please re-enter Tomcat port"
continue
fi
done
}
confirmLicense() {
more ../mongoLicense.txt
echo ""
read -p "I Accept the terms in the license agreement. y or n "
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "license NOT accepted"
exitWithError 0
fi
}
getMongodbpath() {
DB_PATH=${INSTALL_FOLDER}/deployr/database
if [ $NOASK = "false" ] ; then
echo "**********************************************************************"
echo "*"
echo "*"
echo "* Please enter the path to the data directory (dbpath) for the MongoDB database."
echo "* Hit return for default dbpath = ${INSTALL_FOLDER}/deployr/database"
echo "*"
echo "*"
echo "**********************************************************************"
while [ 1 ]
do
read ans
if [ -z "${ans}" ] ; then
break
fi
echo "Is this the correct dbpath ? ${ans}"
echo "Enter y or n"
read ans2
if [[ $ans2 =~ ^[Yy]$ ]] ; then
DB_PATH=$ans
break
else
echo "Please re-enter the dbpath for Mongo"
continue
fi
done
fi
## check user has permissions to write to dbpath
mkdir -p $DB_PATH >> $PWDD/install_log.txt 2>&1
if [ $? -ne 0 ]
then
printAttentionMsg "Unable to create ${DB_PATH}"
echo "Unable to create ${DB_PATH}" >> $PWDD/install_log.txt 2>&1
exit -1
fi
if [ $IS_ROOT -eq 1 ] ; then
cd $DB_PATH
cd ..
chown -R $USER.$GROUP *
chmod -R 775 *
fi
## get full path in case it's a relative path
DB_PATH=`cd "$DB_PATH"; pwd`
}
exitWithError() {
killall -9 $INSTALL_FOLDER/mongo/mongo/bin/mongod
cd $PWDD
rm -rf $INSTALL_FOLDER >> $PWDD/install_log.txt 2>&1
echo "refer to ${PWDD}/install_log.txt for details"
exit $1
}
cd ../
PWDD=`pwd`
source $PWDD/installFiles/properties.sh
source $PWDD/installFiles/java/java.sh $PWDD/installFiles/java
source $PWDD/installFiles/R/findR.sh $PWDD/installFiles/R
source $PWDD/installFiles/rserve/findRserve.sh $PWDD/installFiles/rserve
rm $PWDD/install_log.txt
cd installFiles >> $PWDD/install_log.txt 2>&1
if [ "$HOST_NAME" == " " -o "$HOST_NAME" == "" ]; then
echo "Unable to acquire IP address" | tee -a $PWDD/install_log.txt 2>&1
exit -1
fi
start "$@"