optimize size and time using "--no-cache-dir"
[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-2019 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/ccsdk}
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 #
49 # Wait for database to init properly
50 #
51 echo "Waiting for mysql"
52 until mysql -h dbhost -u root -p${MYSQL_PASSWD} mysql &> /dev/null
53 do
54   printf "."
55   sleep 1
56 done
57 echo -e "\nmysql ready"
58
59 if [ ! -f ${SDNC_HOME}/.installed ]
60 then
61         echo "Installing SDNC database"
62         ${SDNC_HOME}/bin/installSdncDb.sh
63         echo "Installing APPC database"
64         ${APPC_HOME}/bin/installAppcDb.sh
65         echo "Installing ODL Host Key"
66         ${SDNC_HOME}/bin/installOdlHostKey.sh
67
68         if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
69         then
70                 echo "Installing directed graphs"
71                 ${SDNC_HOME}/svclogic/bin/install.sh
72         fi
73         
74         
75         
76
77         if [ -x ${APPC_HOME}/svclogic/bin/install-converted-dgs.sh ]
78         then
79                 echo "Installing APPC JSON DGs converted to XML using dg-loader"
80                 ${APPC_HOME}/svclogic/bin/install-converted-dgs.sh
81         fi
82         
83 echo "Installed at `date`" > ${SDNC_HOME}/.installed
84 fi
85
86 echo "Starting cdt-proxy-service jar, logging to ${APPC_HOME}/cdt-proxy-service/jar.log"
87 java -jar ${APPC_HOME}/cdt-proxy-service/cdt-proxy-service.jar > ${APPC_HOME}/cdt-proxy-service/jar.log &
88
89 echo "Starting dmaap-event-service jar, logging to ${APPC_HOME}/dmaap-event-service/jar.log"
90 java -jar -Dorg_onap_appc_bootstrap_path=/opt/onap/appc/data/properties -Dorg_onap_appc_bootstrap_file=appc.properties ${APPC_HOME}/dmaap-event-service/dmaap-event-service.jar > ${APPC_HOME}/dmaap-event-service/jar.log &
91
92 echo "Starting ODL/APPC"
93
94 #echo "Copying the aaa shiro configuration into opendaylight"
95 #cp ${APPC_HOME}/data/aaa-app-config.xml ${ODL_HOME}/etc/opendaylight/datastore/initial/config/aaa-app-config.xml
96
97 echo "Adding a property system.properties for AAF cadi.properties location"
98 echo "" >> ${ODL_HOME}/etc/system.properties
99 echo "cadi_prop_files=${APPC_HOME}/data/properties/cadi.properties" >> ${ODL_HOME}/etc/system.properties
100 echo "" >> ${ODL_HOME}/etc/system.properties
101
102 echo "Adding a value to property appc.asdc.env in appc.properties for appc-asdc-listener feature"
103 echo "" >> $APPC_HOME/data/properties/appc.properties
104 echo "appc.asdc.env=$DMAAP_TOPIC_ENV" >> $APPC_HOME/data/properties/appc.properties
105 echo "" >> $APPC_HOME/data/properties/appc.properties
106
107 echo "Copying jetty, keystore for https into opendalight"
108 cp ${APPC_HOME}/data/jetty.xml ${ODL_HOME}/etc/jetty.xml
109 cp ${APPC_HOME}/data/keystore ${ODL_HOME}/etc/keystore
110 cp ${APPC_HOME}/data/custom.properties ${ODL_HOME}/etc/custom.properties
111
112 echo "Copying a working version of the logging configuration into the opendaylight etc folder"
113 cp ${APPC_HOME}/data/org.ops4j.pax.logging.cfg ${ODL_HOME}/etc/org.ops4j.pax.logging.cfg
114
115 ODL_BOOT_FEATURES_EXTRA="odl-netconf-connector,odl-restconf-noauth,odl-netconf-clustered-topology,odl-mdsal-clustering"
116 sed -i -e "\|featuresBoot[^a-zA-Z]|s|$|,${ODL_BOOT_FEATURES_EXTRA}|"  $ODL_HOME/etc/org.apache.karaf.features.cfg
117
118 exec ${APPC_HOME}/bin/dockerInstall.sh &
119 echo "Starting OpenDaylight"
120 exec ${ODL_HOME}/bin/karaf server