Fixed the Instantiation Problem of Engine
[holmes/engine-management.git] / engine-d-standalone / src / main / assembly / bin / run.sh
1 #!/bin/bash
2
3 #
4 # Copyright 2017 ZTE Corporation.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19 DIRNAME=`dirname $0`
20 RUNHOME=`cd $DIRNAME/; pwd`
21 echo @RUNHOME@ $RUNHOME
22
23 echo @JAVA_HOME@ $JAVA_HOME
24 JAVA="$JAVA_HOME/bin/java"
25 echo @JAVA@ $JAVA
26 main_path=$RUNHOME/..
27 cd $main_path
28 JAVA_OPTS="-Xms50m -Xmx128m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9202,server=y,suspend=n"
29 port=8312
30 #JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$port,server=y,suspend=n"
31 echo @JAVA_OPTS@ $JAVA_OPTS
32
33 class_path="$main_path/:$main_path/holmes-engine-d.jar"
34 echo @class_path@ $class_path
35
36 sed -i "s/activemq.username=.*/activemq.username=activemq/" /home/activemq/apache-activemq-5.9.0/conf/credentials.properties
37 sed -i "s/activemq.password=.*/activemq.password=v1/" /home/activemq/apache-activemq-5.9.0/conf/credentials.properties
38 /home/activemq/apache-activemq-5.9.0/bin/activemq start
39
40 if [ -z ${JDBC_USERNAME} ]; then
41     export JDBC_USERNAME=holmes
42     echo "No user name is specified for the database. Use the default value \"$JDBC_USERNAME\"."
43 fi
44
45 if [ -z ${JDBC_PASSWORD} ]; then
46     export JDBC_PASSWORD=holmespwd
47     echo "No password is specified for the database. Use the default value \"$JDBC_PASSWORD\"."
48 fi
49
50 if [ -z ${DB_NAME} ]; then
51     export DB_NAME=holmes
52     echo "No database is name is specified. Use the default value \"$DB_NAME\"."
53 fi
54
55 sed -i "s|url:.*|url: jdbc:postgresql://$URL_JDBC/$DB_NAME|" "$main_path/conf/engine-d.yml"
56 sed -i "s|user:.*|user: $JDBC_USERNAME|" "$main_path/conf/engine-d.yml"
57 sed -i "s|password:.*|password: $JDBC_PASSWORD|" "$main_path/conf/engine-d.yml"
58
59 export SERVICE_IP=`hostname -i`
60 echo SERVICE_IP=${SERVICE_IP}
61
62 if [ ! -z ${TESTING} ] && [ ${TESTING} == 1 ]; then
63     if [ ! -z ${HOST_IP} ]; then
64         export HOSTNAME=${HOST_IP}:9102
65     else
66         export HOSTNAME=${SERVICE_IP}:9102
67     fi
68 fi
69
70 #ActiveMQ IP Configurations
71 sed -i "s|brokerIp:.*|brokerIp: $SERVICE_IP|" "$main_path/conf/engine-d.yml"
72
73 KEY_PATH="$main_path/conf/holmes.keystore"
74 KEY_PASSWORD="holmes"
75
76 #HTTPS Configurations
77 sed -i "s|keyStorePath:.*|keyStorePath: $KEY_PATH|" "$main_path/conf/engine-d.yml"
78 sed -i "s|keyStorePassword:.*|keyStorePassword: $KEY_PASSWORD|" "$main_path/conf/engine-d.yml"
79
80 cat "$main_path/conf/engine-d.yml"
81
82
83 "$JAVA" $JAVA_OPTS -classpath "$class_path" org.onap.holmes.engine.EngineDActiveApp server "$main_path/conf/engine-d.yml"
84