3 # Copyright 2017-2021 ZTE Corporation.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 RUNHOME=`cd $DIRNAME/; pwd`
20 echo @RUNHOME@ $RUNHOME
22 echo @JAVA_HOME@ $JAVA_HOME
23 JAVA="$JAVA_HOME/bin/java"
27 JAVA_OPTS="-Xms256m -Xmx1g"
29 #JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=*:$port,server=y,suspend=n"
30 echo @JAVA_OPTS@ $JAVA_OPTS
32 class_path="$main_path/lib/*"
33 echo @class_path@ $class_path
35 if [ -z ${JDBC_USERNAME} ]; then
36 export JDBC_USERNAME=holmes
37 echo "No user name is specified for the database. Use the default value \"$JDBC_USERNAME\"."
40 if [ -z ${JDBC_PASSWORD} ]; then
41 export JDBC_PASSWORD=holmespwd
42 echo "No password is specified for the database. Use the default value \"$JDBC_PASSWORD\"."
45 if [ -z ${DB_NAME} ]; then
47 echo "No database is name is specified. Use the default value \"$DB_NAME\"."
50 # if deployed using helm, use the helm-generated configuration file.
51 if [ -d /opt/hemconfig ]; then
52 cp /opt/hemconfig/engine-d.yml "$main_path/conf/engine-d.yml"
54 sed -i "s|url:.*|url: jdbc:postgresql://$URL_JDBC/$DB_NAME|" "$main_path/conf/engine-d.yml"
55 sed -i "s|user:.*|user: $JDBC_USERNAME|" "$main_path/conf/engine-d.yml"
56 sed -i "s|password:.*|password: $JDBC_PASSWORD|" "$main_path/conf/engine-d.yml"
59 export SERVICE_IP=`hostname -i | awk '{print $1}'`
60 echo SERVICE_IP=${SERVICE_IP}
62 if [ ! -z ${HOST_IP} ]; then
63 export HOSTNAME=${HOST_IP}:9102
65 export HOSTNAME=${SERVICE_IP}:9102
69 if [ ! -z ${URL_JDBC} ] && [ `expr index $URL_JDBC :` != 0 ]; then
70 export DB_PORT="${URL_JDBC##*:}"
74 if [ -z ${ENABLE_ENCRYPT} ]; then
75 export ENABLE_ENCRYPT=true
77 echo ENABLE_ENCRYPT=$ENABLE_ENCRYPT
79 KEY_PATH="/opt/onap/conf/holmes.keystore"
82 if [ -f "/opt/app/osaaf/local/org.onap.holmes-engine-mgmt.p12" ]; then
83 KEY_PATH="/opt/app/osaaf/local/org.onap.holmes-engine-mgmt.p12"
84 KEY_PASSWORD=`head -n1 "/opt/app/osaaf/local/mycreds.prop" | cut -d= -f2`
87 echo "KEY_PATH=$KEY_PATH"
88 echo "KEY_PASS=$KEY_PASSWORD"
91 sed -i "s|keyStorePath:.*|keyStorePath: $KEY_PATH|" "$main_path/conf/engine-d.yml"
92 sed -i "s|keyStorePassword:.*|keyStorePassword: $KEY_PASSWORD|" "$main_path/conf/engine-d.yml"
94 if [ "${ENABLE_ENCRYPT}"x = "true"x ]; then
95 sed -i "s|type:\s*https\?$|type: https|" "$main_path/conf/engine-d.yml"
96 sed -i "s|#\?keyStorePath|keyStorePath|" "$main_path/conf/engine-d.yml"
97 sed -i "s|#\?keyStorePassword|keyStorePassword|" "$main_path/conf/engine-d.yml"
98 sed -i "s|#\?validateCerts|validateCerts|" "$main_path/conf/engine-d.yml"
99 sed -i "s|#\?validatePeers|validatePeers|" "$main_path/conf/engine-d.yml"
101 sed -i 's|type:\s*https\?$|type: http|' "$main_path/conf/engine-d.yml"
102 sed -i "s|#\?keyStorePath|#keyStorePath|" "$main_path/conf/engine-d.yml"
103 sed -i "s|#\?keyStorePassword|#keyStorePassword|" "$main_path/conf/engine-d.yml"
104 sed -i "s|#\?validateCerts|#validateCerts|" "$main_path/conf/engine-d.yml"
105 sed -i "s|#\?validatePeers|#validatePeers|" "$main_path/conf/engine-d.yml"
108 cat "$main_path/conf/engine-d.yml"
110 ${RUNHOME}/initDB.sh "$JDBC_USERNAME" "$JDBC_PASSWORD" "$DB_NAME" "$DB_PORT" "${URL_JDBC%:*}"
112 "$JAVA" $JAVA_OPTS -classpath "$class_path" org.onap.holmes.engine.EngineDActiveApp server "$main_path/conf/engine-d.yml"