Port champ-microservice project restructure
[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
25 BASEDIR="/opt/app/champ-service/"
26 AJSC_HOME="$BASEDIR"
27 AJSC_CONF_HOME="$AJSC_HOME/bundleconfig/"
28
29 if [ -z "$CONFIG_HOME" ]; then
30         echo "CONFIG_HOME must be set in order to start up process"
31         exit 1
32 fi
33
34 if [ -z "$KEY_STORE_PASSWORD" ]; then
35         echo "KEY_STORE_PASSWORD must be set in order to start up process"
36         exit 1
37 else
38         echo "KEY_STORE_PASSWORD=$KEY_STORE_PASSWORD\n" >> $AJSC_CONF_HOME/etc/sysprops/sys-props.properties
39 fi
40
41 if [ -z "$KEY_MANAGER_PASSWORD" ]; then
42         echo "KEY_MANAGER_PASSWORD must be set in order to start up process"
43         exit 1
44 else
45         echo "KEY_MANAGER_PASSWORD=$KEY_MANAGER_PASSWORD\n" >> $AJSC_CONF_HOME/etc/sysprops/sys-props.properties
46 fi
47
48 # Add any spring bean configuration files to the Gizmo deployment
49 if [ -n "$SERVICE_BEANS" ]; then
50         echo "Adding the following dynamic service beans to the deployment: "
51         mkdir -p /tmp/champ-service/v1/conf
52         for f in `ls $SERVICE_BEANS`
53         do
54                 cp $SERVICE_BEANS/$f /tmp/champ-service/v1/conf
55                 echo "Adding dynamic service bean $SERVICE_BEANS/$f"
56         done
57         jar uf /opt/app/champ-service/services/champ-service_v1.zip* -C /tmp/ champ-service
58         rm -rf /tmp/champ-service
59 fi
60
61 CLASSPATH="$AJSC_HOME/lib/*"
62 CLASSPATH="$CLASSPATH:$AJSC_HOME/extJars/"
63 CLASSPATH="$CLASSPATH:$AJSC_HOME/etc/"
64
65 # Check to see if the provided implementation exists in the image and add it to the classpath
66 for file in $( find ${BASEDIR}graph-deps/* -maxdepth 0 -type d ); do
67         CURRIMPL=$(echo $file | cut -d"/" -f6)
68         if [ "x$GRAPHIMPL" = "x$CURRIMPL" ]; then
69                 CLASSPATH_GRAPHIMPL=$file
70                 echo "Setting up graph implementation of $GRAPHIMPL"
71         else
72                 SUPPORTED_GRAPHIMPL="$SUPPORTED_GRAPHIMPL $CURRIMPL"
73         fi
74 done
75 if [ -n "$CLASSPATH_GRAPHIMPL" ]; then
76         cp $CLASSPATH_GRAPHIMPL/* $AJSC_HOME/extJars/
77 else
78         echo "Configured graph implementation '$GRAPHIMPL' is not supported. Acceptable implementations are one of: $SUPPORTED_GRAPHIMPL"
79         exit 1
80 fi
81
82 PROPS="-DAJSC_HOME=$AJSC_HOME"
83 PROPS="$PROPS -DAJSC_CONF_HOME=$BASEDIR/bundleconfig/"
84 PROPS="$PROPS -Dlogback.configurationFile=$BASEDIR/bundleconfig/etc/logback.xml"
85 PROPS="$PROPS -DAJSC_SHARED_CONFIG=$AJSC_CONF_HOME"
86 PROPS="$PROPS -DAJSC_SERVICE_NAMESPACE=champ-service"
87 PROPS="$PROPS -DAJSC_SERVICE_VERSION=v1"
88 PROPS="$PROPS -Dserver.port=9522"
89 PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME"
90 JVM_MAX_HEAP=${MAX_HEAP:-1024}
91
92 echo $CLASSPATH
93
94 exec java -Xmx${JVM_MAX_HEAP}m $PROPS -classpath $CLASSPATH com.att.ajsc.runner.Runner context=// sslport=9522