Update to new two-way certificate for AAF
[appc/deployment.git] / installation / appc / src / main / scripts / installZips.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 ###
22
23 if [ -z "$SETTINGS_FILE" -a -z "$GLOBAL_SETTINGS_FILE" -a -s "$HOME"/.m2/settings.xml ]
24 then
25   DEFAULT_MAVEN_SETTINGS=${HOME}/.m2/settings.xml
26   SETTINGS_FILE=${SETTINGS_FILE:-${DEFAULT_MAVEN_SETTINGS}}
27   GLOBAL_SETTINGS_FILE=${GLOBAL_SETTINGS_FILE:-${DEFAULT_MAVEN_SETTINGS}}
28 fi
29
30 APPC_HOME=${APPC_HOME:-/opt/onap/appc}
31 SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc}
32
33 targetDir=${1:-${APPC_HOME}}
34 sdnc_targetDir=${1:-${SDNC_HOME}}
35
36 #We are going to use a series of directories in the docker-stage folder to extract features to.
37 #By extracting features into more than one directory, we can copy them into the docker image in
38 #different parts, creating more even layer sizes in the docker image.
39 featureDir=$2/featureDir
40
41 #This value determine how many feature directories we want. The featutures will be evenly split
42 #into the number of directories specified. Any remainder will be put into the last directory.
43 #IF THE FEATURES_DIRECTORY_COUNT IS CHANGED, THE DOCKERFILE MUST ALSO BE UPDATED SINCE IT CONTAINS
44 #A COPY COMMAND FOR EACH FEATURE DIRECTORY!! See the Dockerfile for more information.
45 FEATURE_DIRECTORY_COUNT=4
46
47 APPC_FEATURES=" \
48  appc-sdc-listener \
49  appc-lifecycle-management \
50  appc-provider \
51  appc-event-listener \
52  appc-dispatcher \
53  appc-chef-adapter \
54  appc-netconf-adapter \
55  appc-rest-adapter \
56  appc-dmaap-adapter \
57  appc-dg-util \
58  appc-metric \
59  appc-dg-shared \
60  appc-iaas-adapter \
61  appc-ansible-adapter \
62  appc-oam \
63  appc-sequence-generator \
64  appc-config-generator \
65  appc-config-data-services \
66  appc-artifact-handler \
67  appc-config-adaptor \
68  appc-config-audit \
69  appc-config-encryption-tool \
70  appc-config-flow-controller \
71  appc-config-params \
72  appc-aai-client \
73  appc-network-inventory-client \
74  appc-design-services \
75  appc-interfaces-service"
76
77 FEATURES_PER_DIRECTORY=$(($(echo $APPC_FEATURES|wc -w)/$FEATURE_DIRECTORY_COUNT))
78
79 APPC_VERSION=${APPC_VERSION:-0.0.1}
80 APPC_CDT_VERSION=${APPC_CDT_VERSION:-0.0.1}
81 APPC_OAM_VERSION=${APPC_OAM_VERSION:-0.1.1}
82 AAF_SHIRO_VERSION=${AAF_SHIRO_VERSION:-2.1.0-SNAPSHOT}
83
84 if [ ! -d ${targetDir} ]
85 then
86   mkdir -p ${targetDir}
87 fi
88
89 cwd=$(pwd)
90
91 mavenOpts="-s ${SETTINGS_FILE} -gs ${GLOBAL_SETTINGS_FILE}"
92 cd /tmp
93
94 echo "Installing APP-C version ${APPC_VERSION}"
95
96 #The math for splitting up the features into folders
97 featureNumber=1
98 featureDirNumber=1
99 for feature in ${APPC_FEATURES}
100 do
101 if (( $featureDirNumber < $FEATURE_DIRECTORY_COUNT ))
102 then
103   if (( $featureNumber > $FEATURES_PER_DIRECTORY ))
104   then
105     featureDirNumber=$(($featureDirNumber+1))
106     featureNumber=1
107   fi
108 fi
109
110  rm -f /tmp/${feature}-installer*.zip
111  mvn -U ${mavenOpts} org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=org.onap.appc:${feature}-installer:${APPC_VERSION}:zip -DoutputDirectory=/tmp -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.ssl.insecure=true
112  unzip -d ${featureDir}$featureDirNumber /tmp/${feature}-installer*zip
113 featureNumber=$(($featureNumber+1))
114 done
115
116 echo "Installing platform-logic for APP-C"
117 rm -f /tmp/platform-logic-installer*.zip
118 mvn -U ${mavenOpts} org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=org.onap.appc.deployment:platform-logic-installer:${APPC_OAM_VERSION}:zip -DoutputDirectory=/tmp -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.ssl.insecure=true
119 unzip -d ${targetDir} /tmp/platform-logic-installer*.zip
120
121 echo "Downloading dg-loader DGs from nexus"
122 mvn -U ${mavenOpts} org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=org.onap.appc:appc-dg-provider:${APPC_VERSION} -DoutputDirectory=/tmp
123 unzip -d ${targetDir}/svclogic/graphs/appc/json /tmp/appc-dg-provider*.jar json/**
124 mv ${targetDir}/svclogic/graphs/appc/json/json ${targetDir}/svclogic/graphs/appc/json/dg-loader-dgs
125
126 echo "Downloading dg-loader-provider jar from nexus"
127 mvn -U ${mavenOpts} org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=org.onap.appc.plugins:dg-loader-provider:${APPC_VERSION}:jar:jar-with-dependencies -DoutputDirectory=${targetDir}/data
128 mv ${targetDir}/data/dg-loader-provider-*-jar-with-dependencies.jar ${targetDir}/data/dg-loader-provider-jar-with-dependencies.jar
129
130 echo "Downloading aaf-cadi-shiro from nexus"
131 mvn -U ${mavenOpts} org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=org.onap.aaf.authz:aaf-shiro-aafrealm-osgi-bundle:${AAF_SHIRO_VERSION} -DoutputDirectory=${targetDir}/data
132 mv ${targetDir}/data/aaf-shiro-aafrealm-osgi-bundle-*.jar ${targetDir}/data/aaf-shiro-aafrealm-osgi-bundle.jar
133
134 echo "Setting keyfile to readonly"
135 chmod 400 ${targetDir}/data/stores/org.onap.appc.keyfile
136
137 echo "Downloading CDT Proxy Jar from nexus"
138 mvn -U ${mavenOpts} org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=org.onap.appc.cdt:cdt-proxy-service:${APPC_CDT_VERSION} -DoutputDirectory=${targetDir}/cdt-proxy-service
139 mv ${targetDir}/cdt-proxy-service/cdt-proxy-service-*.jar ${targetDir}/cdt-proxy-service/cdt-proxy-service.jar
140
141 find ${targetDir} -name '*.sh' -exec chmod +x '{}' \;
142
143 cd $cwd
144