11960043ce06aeab2d82c29a0a77d13873fc1e5f
[appc/deployment.git] / installation / appc / src / main / scripts / dockerInstall.sh
1 #!/bin/bash
2
3 ###
4 # ============LICENSE_START=======================================================
5 # APPC
6 # ================================================================================
7 # Copyright (C) 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 runs during docker image build.
25 # It starts opendaylight, installs the appc features, then shuts down opendaylight.
26 #
27 ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
28 ODL_ADMIN_PASSWORD=${ODL_ADMIN_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U}
29 SDNC_HOME=${SDNC_HOME:-/opt/onap/ccsdk}
30 APPC_HOME=${APPC_HOME:-/opt/onap/appc}
31 SLEEP_TIME=${SLEEP_TIME:-120}
32 MYSQL_PASSWD=${MYSQL_PASSWD:-openECOMP1.0}
33
34 appcInstallStartTime=$(date +%s)
35
36
37
38 echo "Starting OpenDaylight"
39 ${ODL_HOME}/bin/start
40 echo "Waiting ${SLEEP_TIME} seconds for OpenDaylight to initialize"
41 sleep ${SLEEP_TIME}
42
43 echo "Copying a working version of the logging configuration into the opendaylight etc folder"
44 cp ${APPC_HOME}/data/org.ops4j.pax.logging.cfg ${ODL_HOME}/etc/org.ops4j.pax.logging.cfg
45 echo "Copying a new version of aaf cadi shiro into the opendaylight deploy folder"
46 cp ${APPC_HOME}/data/aaf-shiro-aafrealm-osgi-bundle.jar ${ODL_HOME}/deploy/aaf-shiro-aafrealm-osgi-bundle.jar
47
48 echo "Installing APPC platform features"
49 ${APPC_HOME}/bin/installFeatures.sh
50
51 echo "Adding a property system.properties for AAF cadi.properties location"
52 echo "" >> ${ODL_HOME}/etc/system.properties
53 echo "cadi_prop_files=${APPC_HOME}/data/properties/cadi.properties" >> ${ODL_HOME}/etc/system.properties
54 echo "" >> ${ODL_HOME}/etc/system.properties
55
56 echo "Adding a value to property appc.asdc.env in appc.properties for appc-asdc-listener feature"
57 echo "" >> $APPC_HOME/data/properties/appc.properties
58 echo "appc.asdc.env=$DMAAP_TOPIC_ENV" >> $APPC_HOME/data/properties/appc.properties
59 echo "" >> $APPC_HOME/data/properties/appc.properties
60
61 echo "Copying the aaa shiro configuration into opendaylight"
62 cp ${APPC_HOME}/data/aaa-app-config.xml ${ODL_HOME}/etc/opendaylight/datastore/initial/config/aaa-app-config.xml
63
64 echo "Stopping OpenDaylight"
65 ${ODL_HOME}/bin/stop
66 checkRun () {
67   running=0
68   while read a b c d e f g h
69   do
70     if [ "$h" == "/bin/sh /opt/opendaylight/bin/karaf server" ]
71     then
72       running=1
73     fi
74   done < <(ps -eaf)
75   echo $running
76 }
77
78 while [ $( checkRun ) == 1 ]
79 do
80   echo "Karaf is still running, waiting..."
81   sleep 5s
82 done
83 echo "Karaf process has stopped"
84 sleep 10s
85
86 appcInstallEndTime=$(date +%s)
87 echo "Total Appc install took $(expr $appcInstallEndTime - $appcInstallStartTime) seconds"