add AAF configuration files
[appc/deployment.git] / installation / appc / src / main / scripts / startODL.sh
1 #!/bin/bash
2
3 ###
4 # ============LICENSE_START=======================================================
5 # APPC
6 # ================================================================================
7 # Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
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 ###
22
23 #
24 # This script takes care of installing the SDNC & APPC platform components 
25 #  if not already installed, and starts the APPC Docker Container
26 #
27
28 ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
29 ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
30 SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc}
31 APPC_HOME=${APPC_HOME:-/opt/onap/appc}
32 SLEEP_TIME=${SLEEP_TIME:-120}
33 MYSQL_PASSWD=${MYSQL_PASSWD:-openECOMP1.0}
34
35 #
36 # Adding the DMAAP_TOPIC_ENV variable into APPC-ASDC-LISTENER properties
37 #
38 DMAAP_TOPIC_ENV=${DMAAP_TOPIC_ENV}
39
40 if [ -z "$DMAAP_TOPIC_ENV" ]
41         then
42         echo "DMAAP_TOPIC_ENV shell variable is empty. Adding default value OS-ETE-DFW"
43                 DMAAP_TOPIC_ENV="OS-ETE-DFW"
44         else
45                 echo "DMAAP_TOPIC_ENV shell variable exists and it's $DMAAP_TOPIC_ENV"
46 fi
47
48 echo "Adding a value to property appc.asdc.env in appc.properties for appc-asdc-listener feature"
49 echo "" >> $APPC_HOME/data/properties/appc.properties
50 echo "appc.asdc.env=$DMAAP_TOPIC_ENV" >> $APPC_HOME/data/properties/appc.properties
51 echo "" >> $APPC_HOME/data/properties/appc.properties
52
53 #
54 # Wait for database to init properly
55 #
56 echo "Waiting for mysql"
57 until mysql -h dbhost -u root -p${MYSQL_PASSWD} mysql &> /dev/null
58 do
59   printf "."
60   sleep 1
61 done
62 echo -e "\nmysql ready"
63
64 if [ ! -f ${SDNC_HOME}/.installed ]
65 then
66         echo "Installing SDNC database"
67         ${SDNC_HOME}/bin/installSdncDb.sh
68         echo "Installing APPC database"
69         ${APPC_HOME}/bin/installAppcDb.sh
70         echo "Starting OpenDaylight"
71         ${ODL_HOME}/bin/start
72         echo "Waiting ${SLEEP_TIME} seconds for OpenDaylight to initialize"
73         sleep ${SLEEP_TIME}
74         echo "Inserting modified installFeatures.sh for sdnc"
75         rm ${SDNC_HOME}/bin/installFeatures.sh
76         cp ${APPC_HOME}/data/sdncInstallFeatures.sh ${SDNC_HOME}/bin/installFeatures.sh
77         echo "Copying a working version of the logging configuration into the opendaylight etc folder"
78         cp ${APPC_HOME}/data/org.ops4j.pax.logging.cfg ${ODL_HOME}/etc/org.ops4j.pax.logging.cfg
79         echo "Installing SDNC platform features"
80         ${SDNC_HOME}/bin/installFeatures.sh
81         if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
82         then
83                 echo "Installing directed graphs"
84                 ${SDNC_HOME}/svclogic/bin/install.sh
85         fi
86         
87         echo "Installing APPC platform features"
88         ${APPC_HOME}/bin/installFeatures.sh
89         if [ -x ${APPC_HOME}/svclogic/bin/install.sh ]
90         then
91                 echo "Installing APPC DGs using platform-logic"
92                 ${APPC_HOME}/svclogic/bin/install.sh
93         fi
94
95         if [ -x ${APPC_HOME}/svclogic/bin/install-converted-dgs.sh ]
96         then
97                 echo "Installing APPC JSON DGs converted to XML using dg-loader"
98                 ${APPC_HOME}/svclogic/bin/install-converted-dgs.sh
99         fi
100         
101         echo "Adding a property system.properties for AAF cadi.properties location"
102         echo "" >> ${ODL_HOME}/etc/system.properties
103         echo "cadi_prop_files=${APPC_HOME}/data/properties/cadi.properties" >> ${ODL_HOME}/etc/system.properties
104         echo "" >> ${ODL_HOME}/etc/system.properties
105         
106         echo "Copying a working version of the shiro configuration into the opendaylight etc folder"
107         cp ${APPC_HOME}/data/shiro.ini ${ODL_HOME}/etc/shiro.ini
108
109         echo "Restarting OpenDaylight"
110         ${ODL_HOME}/bin/stop
111         echo "Installed at `date`" > ${SDNC_HOME}/.installed
112 fi
113
114 exec ${ODL_HOME}/bin/karaf