fd02e15e791e2fe4357b3c89ee2a1c92cb26772d
[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 # Install SDN-C & APP-C platform components if not already installed and start container
25
26 ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
27 ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
28 SDNC_HOME=${SDNC_HOME:-/opt/openecomp/sdnc}
29 APPC_HOME=${APPC_HOME:-/opt/openecomp/appc}
30 SLEEP_TIME=${SLEEP_TIME:-120}
31 MYSQL_PASSWD=${MYSQL_PASSWD:-openECOMP1.0}
32
33 #
34 # Adding the DMAAP_TOPIC_ENV variable into APPC-ASDC-LISTENER properties
35 #
36 DMAAP_TOPIC_ENV=${DMAAP_TOPIC_ENV}
37
38 if [ -z "$DMAAP_TOPIC_ENV" ]
39         then
40         echo "DMAAP_TOPIC_ENV shell variable is empty. Adding default value OS-ETE-DFW"
41                 DMAAP_TOPIC_ENV="OS-ETE-DFW"
42         else
43                 echo "DMAAP_TOPIC_ENV shell variable exists and it's $DMAAP_TOPIC_ENV"
44 fi
45
46
47 echo "Adding a value to property appc.asdc.env in appc.properties for appc-asdc-listener feature"
48 echo "" >> $APPC_HOME/data/properties/appc.properties
49 echo "appc.asdc.env=$DMAAP_TOPIC_ENV" >> $APPC_HOME/data/properties/appc.properties
50 echo "" >> $APPC_HOME/data/properties/appc.properties
51
52
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 SDN-C database"
68         ${SDNC_HOME}/bin/installSdncDb.sh
69         echo "Starting OpenDaylight"
70         ${ODL_HOME}/bin/start
71         echo "Waiting ${SLEEP_TIME} seconds for OpenDaylight to initialize"
72         sleep ${SLEEP_TIME}
73         echo "Installing SDN-C platform features"
74         ${SDNC_HOME}/bin/installFeatures.sh
75         if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
76         then
77                 echo "Installing directed graphs"
78                 ${SDNC_HOME}/svclogic/bin/install.sh
79         fi
80         
81         echo "Installing APP-C platform features"
82         ${APPC_HOME}/bin/installFeatures.sh
83         if [ -x ${APPC_HOME}/svclogic/bin/install.sh ]
84         then
85                 echo "Installing directed graphs for APP-C"
86                 ${APPC_HOME}/svclogic/bin/install.sh
87         fi
88
89         echo "Restarting OpenDaylight"
90         ${ODL_HOME}/bin/stop
91         echo "Installed at `date`" > ${SDNC_HOME}/.installed
92 fi
93
94 exec ${ODL_HOME}/bin/karaf