optimize size and time using "--no-cache-dir"
[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}
28 SDNC_HOME=${SDNC_HOME:-/opt/onap/ccsdk}
29 APPC_HOME=${APPC_HOME:-/opt/onap/appc}
30
31 appcInstallStartTime=$(date +%s)
32
33 TIME_OUT=1000
34 INTERVAL=30
35 TIME=0
36 echo "Checking that Karaf can be accessed"
37 while [ "$TIME" -lt "$TIME_OUT" ]; do
38
39 ##clientOutput=$(${ODL_HOME}/bin/client shell:echo KarafLoginCheckIsWorking)
40   clientOutput=$(sshpass -pkaraf ssh -o StrictHostKeyChecking=no karaf@localhost -p 8101 "shell:echo KarafLoginCheckIsWorking")
41   if echo "$clientOutput" | grep -q "KarafLoginCheckIsWorking"; then
42     echo "Karaf login succeeded"
43     echo localhost ready in $TIME seconds
44     break;
45   else
46      echo Sleep: $INTERVAL seconds before localhost address is ready. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
47   fi
48
49   sleep $INTERVAL
50   TIME=$(($TIME+$INTERVAL))
51 done
52
53 if [ "$TIME" -ge "$TIME_OUT" ]; then
54   echo "Error during Karaf login, abort manual run dockerInstall.sh to instaill APPC platform features"
55   exit 1
56 fi
57
58 echo "Karaf login is ready, installing APPC platform features"
59 ${APPC_HOME}/bin/installFeatures.sh
60
61 appcInstallEndTime=$(date +%s)
62 echo "Total Appc install took $(expr $appcInstallEndTime - $appcInstallStartTime) seconds"