bf29db593cc1ca6256184baec8b7294058e4007f
[aai/champ.git] / champ-service / src / main / bin / start.sh
1 #!/bin/sh
2 #
3 # ============LICENSE_START==========================================
4 # org.onap.aai
5 # ===================================================================
6 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
7 # Copyright © 2017 Amdocs
8 # ===================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 #        http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END============================================
21 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 #
23
24 APP_HOME="/opt/app/champ-service"
25 GRAPH_DEPS_HOME="${APP_HOME}/graph-deps"
26
27 if [ -z "$CONFIG_HOME" ]; then
28     echo "CONFIG_HOME must be set in order to start up process"
29     exit 1
30 fi
31
32 if [ -z "$KEY_STORE_PASSWORD" ]; then
33     echo "KEY_STORE_PASSWORD must be set in order to start up process"
34     exit 1
35 fi
36
37 if [ -z "$SERVICE_BEANS" ]; then
38     echo "SERVICE_BEANS must be set in order to start up process"
39     exit 1
40 fi
41
42 for dir in $( find ${GRAPH_DEPS_HOME}/* -maxdepth 0 -type d ); do
43     CURRIMPL=$(basename $dir)
44     if [ "x$GRAPHIMPL" = "x$CURRIMPL" ]; then
45         GRAPHIMPL_DEPS="${GRAPH_DEPS_HOME}/${GRAPHIMPL}"
46         echo "Setting up graph implementation to $GRAPHIMPL"
47     else
48         SUPPORTED_GRAPHIMPL="$SUPPORTED_GRAPHIMPL $CURRIMPL"
49     fi
50 done
51
52 if [ -z "$GRAPHIMPL_DEPS" ]; then
53     echo "Configured graph implementation '$GRAPHIMPL' is not supported. Acceptable implementations are one of: $SUPPORTED_GRAPHIMPL"
54     exit 1
55 fi
56
57 PROPS="-DAPP_HOME=$APP_HOME"
58 PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME"
59 PROPS="$PROPS -Dlogging.config=$APP_HOME/bundleconfig/etc/logback.xml"
60 PROPS="$PROPS -DKEY_STORE_PASSWORD=$KEY_STORE_PASSWORD"
61
62 if [ ! -z "$TRUST_STORE_PASSWORD" ]; then
63    PROPS="$PROPS -DTRUST_STORE_PASSWORD=${TRUST_STORE_PASSWORD}"
64 fi
65
66 if [ ! -z "$TRUST_STORE_LOCATION" ]; then
67    PROPS="$PROPS -DTRUST_STORE_LOCATION=${TRUST_STORE_LOCATION}"
68 fi
69
70 JVM_MAX_HEAP=${MAX_HEAP:-1024}
71
72 set -x
73 exec java -Xmx${JVM_MAX_HEAP}m $PROPS -Dloader.path="${GRAPHIMPL_DEPS}" -jar "${APP_HOME}/champ-service.jar"