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