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