-
Notifications
You must be signed in to change notification settings - Fork 4
/
bootstrap
executable file
·572 lines (522 loc) · 20.7 KB
/
bootstrap
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
#!/bin/sh
#
# This script allows you to install Nubomedia PaaS API. To execute it:
#
# 'curl -fsSkL https://raw.githubusercontent.com/nubomedia/nubomedia-msvnfm/master/bootstrap | bash'
. /lib/lsb/init-functions
#general configuration
_PROJECT_NAME="nubomedia-msvnfm"
_BASE="/opt"
_PROJECT_ROOT_BASE="${_BASE}/nubomedia"
_PROJECT_BASE="${_PROJECT_ROOT_BASE}/${_PROJECT_NAME}"
_PROJECT_PROPERTIES_FOLDER="/etc/nubomedia"
_DEFAULT_PROPERTIES_FILE="${_PROJECT_BASE}/etc/msvnfm.properties"
_PROJECT_PROPERTIES_FILE="${_PROJECT_PROPERTIES_FOLDER}/msvnfm.properties"
_PROJECT_LOG_FOLDER="/var/log/nubomedia"
_DATABASE_NAME="nubomedia"
#debian configuration
_APT_KEY_SERVER="keyserver.ubuntu.com"
_APT_KEY_SERVER_KEY="F04B5A6F"
_APT_REPOSITORY="deb http://repository.nubomedia.eu/ trusty main"
#git configuration
_PROJECT_REPO="https://github.com/nubomedia/nubomedia-msvnfm.git"
_SCRIPT_NAME="ms-vnfm.sh"
#_TAG="develop"
_TAG="tags/1.3.2"
_USER="$(id -un 2>/dev/null || true)"
checkBinary () {
if command -v $1 >/dev/null 2>&1 ; then
log_success_msg "Checking for '$1'"
return 0
else
log_failure_msg "Checking for '$1'"
return 1
fi
}
_ex='sh -c'
if [ "$_USER" != 'root' ]; then
if checkBinary sudo; then
_ex='sudo -E sh -c'
elif checkBinary su; then
_ex='su -c'
fi
fi
# Checks if the function call of setting properties got the expected values
# $1: description shown for entering value (mandatory)
# $2: configuration property (mandatory)
# $3: default configuration value (optional)
checkPropertyConfiguration () {
# Checking if the description is given
if [ -z "$1" ]; then
echo "-Parameter #1 is not set. Please provide the description of this configration parameter."
return 1
# Checking if the configuration parameter is given
elif [ -z "$2" ]; then
echo "-Parameter #2 is not set. Please provide the configration parameter."
return 1
fi
# Reading the value from the user
export _VALUE
read -p "$1 [$3]:" _VALUE
# Checking if at least one of both values is defined (either default or defined)
if [ -z "${_VALUE}" ] && [ -z "${3}" ]; then
log_failure_msg "You have to provide a value for \"$2\" since there is no default"
checkPropertyConfiguration "$1" "$2" "$3"
elif [ ! -z "${_VALUE}" ]; then
setProperty $2 $_VALUE
log_success_msg "Set parameter \"$2\" to value \"$_VALUE\""
elif [ ! -z "${3}" ]; then
setProperty $2 $3
log_success_msg "Kept parameter \"$2\" as the default value \"$3\""
fi
}
# Set the properties in the configuration file (no further checks)
# $1: configuration property (mandatory)
# $2: configuration property value (mandatory)
setProperty () {
$_ex 'sed -i "s|^'"$1"'=.*|'"$1"'="'$2'"|g" '"$_PROJECT_PROPERTIES_FILE"
}
#property configuration
configureProperties () {
echo "The properties file to change is: $_PROJECT_PROPERTIES_FILE"
echo "NUBOMEDIA Media Server VNF Manager (EMM) configuration"
checkPropertyConfiguration "Enter the port of the VNF Manager" "paas.port" "9000"
if askForConfiguration "Do you want to configure a STUN server?"; then
checkPropertyConfiguration "Do you want to enable the usage of a STUN server" "mediaserver.stun-server.activate" "false"
checkPropertyConfiguration "Enter the IP of the STUN server" "mediaserver.stun-server.address" ""
checkPropertyConfiguration "Enter the port of the STUN server" "mediaserver.stun-server.port" ""
fi
if askForConfiguration "Do you want to configure a TURN server?"; then
checkPropertyConfiguration "Do you want to enable the usage of a TURN server" "mediaserver.turn-server.activate" "false"
checkPropertyConfiguration "Enter the URL of the TURN server" "mediaserver.turn-server.url" ""
checkPropertyConfiguration "Enter the username to authorize against the TURN server" "mediaserver.turn-server.username" ""
checkPropertyConfiguration "Enter the password to authorize against the TURN server" "mediaserver.turn-server.password" ""
fi
echo
echo "NFVO configuration"
checkPropertyConfiguration "Enter the username to authorize against the Orchestrator" "nfvo.username" "admin"
checkPropertyConfiguration "Enter the password to authorize against the Orchestrator" "nfvo.password" ""
echo
echo "AutoScaling configuration"
if askForConfiguration "Do you want to configure the pool mechanism?"; then
checkPropertyConfiguration "Do you want to enable the pool mechanism for auto scaling?" "autoscaling.pool.activate" "false"
checkPropertyConfiguration "Enter the pool size that should be created in advance" "autoscaling.pool.size" "1"
checkPropertyConfiguration "Enter the period of checking the policies" "autoscaling.pool.period" "30"
checkPropertyConfiguration "Should the pool be created in advance?" "autoscaling.pool.prepare" "false"
fi
checkPropertyConfiguration "Do you want to enable termination rules when scaling-in?" "autoscaling.termination-rule.activate" "false"
}
askForConfiguration () {
echo "$1"
echo "1) Yes"
echo "2) No (default)"
read -p "Your choice: " choice
case $choice in
1) return 0;;
2) return 1;;
*) return 1;;
esac
}
##################
#### database ####
##################
configureDatabase () {
echo "Do you wish to use MySQL?"
echo "1) Yes"
echo "2) No (default)"
read -p "Your choice: " choice
case $choice in
1) installMySql
configureMySql;;
2) return 0;;
*) return 0;;
esac
}
###############
#### MySQL ####
###############
installMySql () {
checkBinary mysql; _error=$(($_error + $?))
if [ "0" != "$_error" ]; then
log_warning_msg "MySQL is not yet installed. Start installation ..."
$_ex 'apt-get -y install mysql-server'
fi
}
#requests the MySQL root password
#additionally, it checks if the root password is valid
#if not, it is asked again for the right password
getMySqlRootPw () {
stty -echo
read -p "Please, provide the password of the root user of mysql: " rootpasswd; echo
stty echo
#for empty passwords it is also allowed
#if [ -z "${rootpasswd}" ]; then
# log_failure_msg "You have to provide the root password of MySQL..."
# getMySqlRootPw
# return 0
#fi
#check if root password is correct
mysql -uroot -p${rootpasswd} -e exit
if [ $? -eq 0 ]; then
log_success_msg "MySQL root password validated"
else
log_failure_msg "MySQL root password is wrong ..."
getMySqlRootPw
return 0
fi
}
#creates a new MySQL user
#should always work since it is checked before that the user does not exist
createMySqlUser () {
mysql -uroot -p${rootpasswd} -e "CREATE USER ${sqlUser}@localhost IDENTIFIED BY \"${sqlPassword}\";"
if [ $? -eq 0 ]; then
log_success_msg "Created user"
else
log_failure_msg "Failed to create new MySQL user ${sqlUser}"
exit 1
fi
}
#Checks if the database exists already
#if not, it is created a new
#if yes, it can be decided to keep the database or drop it and create a new one
createMySqlDatabase () {
exist=`mysql -uroot -p*4root# -e "show databases;" | grep "\b${_DATABASE_NAME}\b" | wc -l`
if [ ${exist} -eq 1 ]; then
echo "MySQL database ${_DATABASE_NAME} exists already"
echo "How to proceed?"
echo "1) Keep it (default)"
echo "2) Drop it"
read -p "Your choice: " choice
case $choice in
1) return 0;;
2) mysql -uroot -p*4root# -e "drop database ${_DATABASE_NAME};"
log_success_msg "Dropped database ${_DATABASE_NAME}"
createMySqlDatabase;;
*) return 0;;
esac
else
mysql -uroot -p${rootpasswd} -e "CREATE DATABASE ${_DATABASE_NAME} /*\!40100 DEFAULT CHARACTER SET utf8 */;"
log_success_msg "Created new database ${_DATABASE_NAME}"
fi
}
#configures the database table for the given user
assignMySqlDatabaseRights () {
mysql -uroot -p${rootpasswd} -e "GRANT ALL ON ${_DATABASE_NAME}.* TO '${sqlUser}'@'localhost';"
log_success_msg "Granted rights to user ${sqlUser}"
mysql -uroot -p${rootpasswd} -e "FLUSH PRIVILEGES;"
log_success_msg "Flushed privileges"
mysql -uroot -p${rootpasswd} -e "USE ${_DATABASE_NAME};"
log_success_msg "Changed to database ${_DATABASE_NAME}"
}
#checks if the user exists and credentials are valid
#if the user exist but the password is wrong it goes back to enter the credentials
#if the user doesn't exist, it is created a new one
checkIfMySqlUserExist () {
echo "Checking if user already exists ..."
exist=`mysql -uroot -p${rootpasswd} -e "select * from mysql.user;" | grep "\b${sqlUser}\b" | wc -l`
if [ ${exist} -eq 1 ]; then
echo "MySQL user ${sqlUser} exists already. Checking password..."
mysql -u${sqlUser} -p${sqlPassword} -e exit
if [ $? -eq 0 ]; then
log_success_msg "MySQL password for user ${sqlUser} validated"
return 0
else
log_failure_msg "MySQL password for user ${sqlUser} is wrong ..."
requestMySqlUser
fi
else
echo "Creating a new MySQL user with name ${sqlUser} ..."
createMySqlUser
return 0
fi
}
#reqeusts the user that should be used for MySQL
#additionally, it will be checked if the user exists and can login
requestMySqlUser () {
read -p "Please, enter the name of the mysql user you would like ${_PROJECT_NAME} to use [admin]: " sqlUser
if [ -z "$sqlUser" ]; then
sqlUser=admin
fi
# Turning echo on and off between password reading
stty -echo
read -p "Please, provide the password for this user [changeme]: " sqlPassword; echo
if [ -z "$sqlPassword" ]; then
sqlPassword=changeme
fi
stty echo
checkIfMySqlUserExist
}
#configuring MySQL in the properties file
#Enabling MySQL, disabling HSQL
configureMySql () {
echo "Configuring MySQL for $_PROJECT_NAME ..."
# Request MySQL root password to configure a new user for MySQL
getMySqlRootPw
# Request MySQL to use for this project
requestMySqlUser
# Create the Database
createMySqlDatabase
assignMySqlDatabaseRights
$_ex 'sed -i "s/^spring.jpa.hibernate.ddl-auto=create-drop/spring.jpa.hibernate.ddl-auto=update/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^#spring.datasource.validationQuery=.*/spring.datasource.validationQuery=SELECT 1/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^#spring.datasource.testOnBorrow=.*/spring.datasource.testOnBorrow=true/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^#spring.datasource.url=jdbc:mysql:.*/spring.datasource.url=jdbc:mysql:\/\/localhost:3306\/'"$_DATABASE_NAME"'/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^#spring.datasource.driver-class-name=com.mysql.jdbc.Driver/spring.datasource.driver-class-name=com.mysql.jdbc.Driver/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^#spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect/spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^spring.datasource.username=.*/spring.datasource.username='"${sqlUser}"'/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^spring.datasource.password=.*/spring.datasource.password='"${sqlPassword}"'/g" '"$_PROJECT_PROPERTIES_FILE"
log_success_msg "Enabled MySQL"
$_ex 'sed -i "s/^spring.datasource.url=jdbc:hsqldb:file:\(.*\)/#spring.datasource.url=jdbc:hsqldb:file:\1/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver/#spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect/#spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect/g" '"$_PROJECT_PROPERTIES_FILE"
log_success_msg "Disabled HSQL"
}
##################
#### RabbitMQ ####
##################
configureRabbitMQ () {
checkPropertyConfiguration "Enter the host address where the RabbitMQ server is running" "rabbitmq.host" "localhost"
checkPropertyConfiguration "Enter the username used to authorize against the RabbitMQ server" "rabbitmq.username" ""
checkPropertyConfiguration "Enter the password used to authorize against the RabbitMQ server" "rabbitmq.password" ""
}
######################
#### Using DEBIAN ####
######################
#adding apt repository
#1. add key
#2. add repo
#3. update repositories
addAptRepository () {
if [ -z "$_APT_KEY_SERVER_KEY" ] && [ -z "$_APT_KEY_SERVER" ]; then
log_warning_msg "Either the key server or key for the key server was not defined. Continue with adding the apt repository"
else
echo "Adding key server and key..."
$_ex 'apt-key adv --keyserver '"$_APT_KEY_SERVER"' --recv-keys '"$_APT_KEY_SERVER_KEY"
fi
if [ -n "$_APT_REPOSITORY" ]; then
echo "Adding apt repository..."
$_ex 'add-apt-repository '"\"$_APT_REPOSITORY\""
else
log_error_msg "apt repository is null. Please provide"
fi
$_ex 'apt-get update -y'
}
#isntalls the project
installProject () {
$_ex 'apt-get install -y '"$_PROJECT_NAME"
}
#debian re-start of the project
restartProject () {
instance=$(ps aux | grep -v grep | grep "$_PROJECT_NAME" | grep jar | wc -l)
if [ ${instance} -ne 0 ] ; then
echo "restarting $_PROJECT_NAME ..."
"$_PROJECT_NAME" restart
else
echo "starting $_PROJECT_NAME ..."
"$_PROJECT_NAME" start
fi
}
#########################################
########## Using source code ############
#########################################
prereq () {
$_ex 'apt-get update; apt-get -y install openjdk-7-jdk screen git rabbitmq-server'
log_success_msg "Installed required software"
}
checkEnvironment () {
_error=0
echo "Checking environment..."
checkBinary java; _error=$(($_error + $?))
checkBinary javac; _error=$(($_error + $?))
checkBinary curl; _error=$(($_error + $?))
checkBinary screen; _error=$(($_error + $?))
checkBinary wget; _error=$(($_error + $?))
if [ "0" != "$_error" ]; then
log_failure_msg "FAILED. Please install the above mentioned binaries."
exit 1
fi
}
configureRabbitMq () {
# Allow the use of the .deb package to install Open Baton with Docker (because of issues when installing and configuring RabbitMQ during a docker image build)
# See documentation for more info
echo "Creating RabbitMQ user \"${_PROJECT_NAME}\""
result=`$_ex 'rabbitmqctl list_users' | grep '^'"$_PROJECT_NAME" | wc -l`
if [ ${result} -eq 0 ]; then
rabbitMqPassword=`< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-32};echo;`
$_ex 'rabbitmqctl add_user '"$_PROJECT_NAME"' '"$rabbitMqPassword"
log_success_msg "Created RabbitMQ user \"${_PROJECT_NAME}\""
else
log_warning_msg "User \"${_PROJECT_NAME}\" exists already"
rabbitMqPassword=`< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-32};echo;`
$_ex 'rabbitmqctl change_password '"$_PROJECT_NAME"' '"$rabbitMqPassword"
log_success_msg "Changed password of RabbitMQ user \"${_PROJECT_NAME}\""
fi
$_ex 'rabbitmqctl set_user_tags '"$_PROJECT_NAME"' administrator'
$_ex 'rabbitmqctl set_permissions -p / '"$_PROJECT_NAME"' ".*" ".*" ".*"'
$_ex 'sed -i "s/^rabbitmq.username=.*/rabbitmq.username='"$_PROJECT_NAME"'/g" '"$_PROJECT_PROPERTIES_FILE"
$_ex 'sed -i "s/^rabbitmq.password=.*/rabbitmq.password='"$rabbitMqPassword"'/g" '"$_PROJECT_PROPERTIES_FILE"
log_success_msg "Changed RabbitMQ user in ${_PROJECT_PROPERTIES_FILE}"
#### Workaround to enable rabbitmq management plugin ####
#$_ex 'rabbitmq-plugins enable rabbitmq_management'
if [ -f /etc/rabbitmq/enabled_plugins ]; then
result=$(grep /etc/rabbitmq/enabled_plugins -e "[rabbitmq_management].")
if [ "${result}" != "[rabbitmq_management]." ]; then
$_ex 'echo "[rabbitmq_management]." >> /etc/rabbitmq/enabled_plugins'
fi
else
$_ex 'echo "[rabbitmq_management]." > /etc/rabbitmq/enabled_plugins'
fi
##########################################################
$_ex 'service rabbitmq-server restart'
if [ "$?" != "0" ]; then
log_failure_msg "rabbitmq is not running properly (check the problem in /var/log/rabbitmq)"
exit 1
fi
}
#create the base where the project is cloned to
createBase () {
echo "Creating the ${_PROJECT_NAME} root base folder \"${_PROJECT_ROOT_BASE}\""
if [ -d "${_PROJECT_ROOT_BASE}" ]; then
if [ -d "${_PROJECT_BASE}" ]; then
echo "Base folder \"${_PROJECT_BASE}\" exists already"
echo "How to proceed?"
echo "1) Keep it"
echo "2) Remove it (default)"
read -p "Your choice: " choice
case $choice in
1) return 0;;
2) $_ex 'rm -rf '"$_PROJECT_BASE"
log_success_msg "Removed old base folder";;
*) $_ex 'rm -rf '"$_PROJECT_BASE"
log_success_msg "Removed old base folder";;
esac
fi
else
$_ex 'mkdir -p '"$_PROJECT_ROOT_BASE"
log_success_msg "Created root base folder \"${_PROJECT_ROOT_BASE}\""
fi
$_ex 'chown -R '"$_USER $_PROJECT_ROOT_BASE"
log_success_msg "Configured permissions of root base folder \"${_PROJECT_ROOT_BASE}\""
}
createLogFolder () {
# create log folder and give permission
if [ -d "${_PROJECT_LOG_FOLDER}" ]; then
echo "Log folder \"${_PROJECT_LOG_FOLDER}\" exists already"
echo "How to proceed?"
echo "1) Keep it (default)"
echo "2) Remove it"
read -p "Your choice: " choice
case $choice in
1) return 0;;
2) $_ex 'rm -rf '"$_PROJECT_LOG_FOLDER"
log_success_msg "Removed log folder \"${_PROJECT_LOG_FOLDER}\""
$_ex 'mkdir -p '"$_PROJECT_LOG_FOLDER"
log_success_msg "Created log folder \"${_PROJECT_LOG_FOLDER}\"";;
*) return 0;;
esac
else
$_ex 'mkdir -p '"$_PROJECT_LOG_FOLDER"
log_success_msg "Created log folder \"${_PROJECT_LOG_FOLDER}\""
fi
$_ex 'chown -R '"$_USER $_PROJECT_LOG_FOLDER"
log_success_msg "Configured permissions of log folder \"${_PROJECT_LOG_FOLDER}\""
}
cloneProject () {
echo "Cloning ${_PROJECT_NAME} to ${_PROJECT_BASE} ..."
oldpath=`pwd`
cd "${_PROJECT_ROOT_BASE}"
git clone --recursive "${_PROJECT_REPO}" "${_PROJECT_NAME}"
cd $oldpath
}
checkoutVersion () {
echo "Choose version:"
echo "1) ${_TAG} (default)"
echo "2) master"
echo "3) develop"
read -p "Your choice: " choice
case $choice in
1) version=${_TAG};;
2) version=master;;
3) version=develop;;
*) version=${_TAG};;
esac
oldpath=`pwd`
cd "${_PROJECT_BASE}"
git checkout ${version}
cd $oldpath
}
copyConfigFiles () {
if [ ! -d "${_PROJECT_PROPERTIES_FOLDER}" ]; then
$_ex 'mkdir -p '"${_PROJECT_PROPERTIES_FOLDER}"
log_success_msg "created properties folder"
else
log_warning_msg "Properties folder \"${_PROJECT_PROPERTIES_FOLDER}\" exists already"
fi
$_ex 'cp '"${_DEFAULT_PROPERTIES_FILE} ${_PROJECT_PROPERTIES_FILE}"
log_success_msg "Copied default configuration file \"${_DEFAULT_PROPERTIES_FILE}\" to \"${_PROJECT_PROPERTIES_FOLDER}\""
if [ -d "${_PROJECT_BASE}/etc" ]; then
$_ex 'cp '"${_PROJECT_BASE}/etc/* ${_PROJECT_PROPERTIES_FOLDER}"
log_success_msg "Copied files from \"${_PROJECT_BASE}/etc\" to \"${_PROJECT_PROPERTIES_FOLDER}\""
fi
}
compileProject () {
echo "Compiling ${_PROJECT_NAME}"
oldpath=`pwd`
cd "${_PROJECT_BASE}"
./${_SCRIPT_NAME} compile
if [ $? -ne 0 ]; then
echo "ERROR: The compilation of ${_PROJECT_NAME} failed"
exit 1
fi
cd $oldpath
}
startProject () {
echo "Starting ${_PROJECT_NAME}"
oldpath=`pwd`
cd ${_PROJECT_BASE}
./${_SCRIPT_NAME} start
cd $oldpath
}
#################
### INSTALLER ###
#################
useDebian () {
#Add apt repository
addAptRepository
#Install project
installProject
#ask/configure mysql
configureDatabase
#configure properties
configureProperties
#start or restart project
restartProject
}
useSourceCode () {
prereq
checkEnvironment
createBase
createLogFolder
cloneProject
checkoutVersion
copyConfigFiles
#setPassword #not needed
configureRabbitMq
configureDatabase
configureProperties
compileProject
startProject
}
bootstrap () {
echo "How to install ${_PROJECT_NAME}?"
echo "1) debian (default)"
echo "2) source code via git"
read -p "Your choice: " choice
case $choice in
1) useDebian;;
2) useSourceCode;;
*) useDebian;;
esac
echo "$_PROJECT_NAME is up and running now..."
}
bootstrap