61f23daaa6401f429a8eec493046ad51b153c8bd
[demo.git] / heat / ONAP / cloud-config / aaf_install.sh
1 #!/bin/bash
2
3 # Read configuration files
4 GERRIT_BRANCH=$(cat /opt/config/gerrit_branch.txt)
5 CODE_REPO=$(cat /opt/config/remote_repo.txt)
6 HTTP_PROXY=$(cat /opt/config/http_proxy.txt)
7 HTTPS_PROXY=$(cat /opt/config/https_proxy.txt)
8
9 if [ $HTTP_PROXY != "no_proxy" ]
10 then
11     export http_proxy=$HTTP_PROXY
12     export https_proxy=$HTTPS_PROXY
13 fi
14
15
16 # Download dependencies
17 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >>  /etc/apt/sources.list.d/java.list
18 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >>  /etc/apt/sources.list.d/java.list
19 apt-get update
20 apt-get install --allow-unauthenticated -y openjdk-8-jdk maven
21
22 # Clone Gerrit repository and run docker containers
23 cd /opt
24 git clone -b $GERRIT_BRANCH --single-branch $CODE_REPO
25 chmod +x /opt/authz/auth/auth-cass/docker/dinstall.sh
26 chmod +x /opt/authz/auth/auth-cass/docker/backup/backup.sh
27 chmod +x /opt/authz/auth/docker/dbuild.sh
28 chmod +x /opt/authz/auth/docker/drun.sh
29 chmod +x /opt/authz/auth/docker/dstart.sh
30 chmod +x /opt/authz/auth/docker/dstop.sh
31
32 #Update maven settings
33 cat > /usr/share/maven/conf/settings.xml << EOF
34 <?xml version="1.0" encoding="UTF-8"?>
35
36 <!--
37 Licensed to the Apache Software Foundation (ASF) under one
38 or more contributor license agreements.  See the NOTICE file
39 distributed with this work for additional information
40 regarding copyright ownership.  The ASF licenses this file
41 to you under the Apache License, Version 2.0 (the
42 "License"); you may not use this file except in compliance
43 with the License.  You may obtain a copy of the License at
44
45     http://www.apache.org/licenses/LICENSE-2.0
46
47 Unless required by applicable law or agreed to in writing,
48 software distributed under the License is distributed on an
49 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
50 KIND, either express or implied.  See the License for the
51 specific language governing permissions and limitations
52 under the License.
53 -->
54
55 <!--
56  | This is the configuration file for Maven. It can be specified at two levels:
57  |
58  |  1. User Level. This settings.xml file provides configuration for a single user,
59 |                 and is normally provided in \${user.home}/.m2/settings.xml.
60  |
61  |                 NOTE: This location can be overridden with the CLI option:
62  |
63  |                 -s /path/to/user/settings.xml
64  |
65  |  2. Global Level. This settings.xml file provides configuration for all Maven
66  |                 users on a machine (assuming they're all using the same Maven
67  |                 installation). It's normally provided in
68 |                 \${maven.home}/conf/settings.xml.
69  |
70  |                 NOTE: This location can be overridden with the CLI option:
71  |
72  |                 -gs /path/to/global/settings.xml
73  |
74  | The sections in this sample file are intended to give you a running start at
75  | getting the most out of your Maven installation. Where appropriate, the default
76  | values (values used when the setting is not specified) are provided.
77  |
78  |-->
79 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
80           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
81           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
82   <!-- localRepository
83    | The path to the local repository maven will use to store artifacts.
84    |
85 | Default: \${user.home}/.m2/repository
86   <localRepository>/path/to/local/repo</localRepository>
87   -->
88
89   <!-- interactiveMode
90    | This will determine whether maven prompts you when it needs input. If set to false,
91    | maven will use a sensible default value, perhaps based on some other setting, for
92    | the parameter in question.
93    |
94    | Default: true
95   <interactiveMode>true</interactiveMode>
96   -->
97
98   <!-- offline
99    | Determines whether maven should attempt to connect to the network when executing a build.
100    | This will have an effect on artifact downloads, artifact deployment, and others.
101    |
102    | Default: false
103   <offline>false</offline>
104   -->
105
106   <!-- pluginGroups
107    | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
108    | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
109    | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
110    |-->
111   <pluginGroups>
112     <!-- pluginGroup
113      | Specifies a further group identifier to use for plugin lookup.
114     <pluginGroup>com.your.plugins</pluginGroup>
115     -->
116   </pluginGroups>
117
118 EOF
119
120 if [[ $(cat /opt/config/https_proxy.txt) != "no_proxy" ]]; then
121   HTTPS_PROXY_HOST=$(cat /opt/config/https_proxy.txt | cut -d ':' -f1)
122   HTTPS_PROXY_PORT=$(cat /opt/config/https_proxy.txt | cut -d ':' -f2)
123
124   cat >> settings.xml << EOF
125   <!-- proxies
126    | This is a list of proxies which can be used on this machine to connect to the network.
127    | Unless otherwise specified (by system property or command-line switch), the first proxy
128    | specification in this list marked as active will be used.
129    |-->
130   <proxies>
131     <proxy>
132       <id>optional</id>
133       <active>true</active>
134       <protocol>http</protocol>
135       <username>proxyuser</username>
136       <password>proxypass</password>
137       <host>$HTTPS_PROXY_HOST</host>
138       <port>$HTTPS_PROXY_PORT</port>
139       <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
140     </proxy>
141     <proxy>
142       <id>optional</id>
143       <active>true</active>
144       <protocol>https</protocol>
145       <username>proxyuser</username>
146       <password>proxypass</password>
147       <host>$HTTPS_PROXY_HOST</host>
148       <port>$HTTPS_PROXY_PORT</port>
149       <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
150     </proxy>
151   </proxies>
152
153 EOF
154 fi
155
156 cat >> settings.xml << EOF
157
158   <!-- servers
159    | This is a list of authentication profiles, keyed by the server-id used within the system.
160    | Authentication profiles can be used whenever maven must make a connection to a remote server.
161    |-->
162   <servers>
163     <!-- server
164      | Specifies the authentication information to use when connecting to a particular server, identified by
165      | a unique name within the system (referred to by the 'id' attribute below).
166      |
167      | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
168      |       used together.
169      |
170     <server>
171       <id>deploymentRepo</id>
172       <username>repouser</username>
173       <password>repopwd</password>
174     </server>
175     -->
176
177     <!-- Another sample, using keys to authenticate.
178     <server>
179       <id>siteServer</id>
180       <privateKey>/path/to/private/key</privateKey>
181       <passphrase>optional; leave empty if not used.</passphrase>
182     </server>
183     -->
184   </servers>
185
186   <!-- mirrors
187    | This is a list of mirrors to be used in downloading artifacts from remote repositories.
188    |
189    | It works like this: a POM may declare a repository to use in resolving certain artifacts.
190    | However, this repository may have problems with heavy traffic at times, so people have mirrored
191    | it to several places.
192    |
193    | That repository definition will have a unique id, so we can create a mirror reference for that
194    | repository, to be used as an alternate download site. The mirror site will be the preferred
195    | server for that repository.
196    |-->
197
198   <!-- profiles
199    | This is a list of profiles which can be activated in a variety of ways, and which can modify
200    | the build process. Profiles provided in the settings.xml are intended to provide local machine-
201    | specific paths and repository locations which allow the build to work in the local environment.
202    |
203    | For example, if you have an integration testing plugin - like cactus - that needs to know where
204    | your Tomcat instance is installed, you can provide a variable here such that the variable is
205    | dereferenced during the build process to configure the cactus plugin.
206    |
207    | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
208    | section of this document (settings.xml) - will be discussed later. Another way essentially
209    | relies on the detection of a system property, either matching a particular value for the property,
210    | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
211    | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
212    | Finally, the list of active profiles can be specified directly from the command line.
213    |
214    | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
215    |       repositories, plugin repositories, and free-form properties to be used as configuration
216    |       variables for plugins in the POM.
217    |
218    |-->
219
220
221
222   
223   
224   <profiles>
225       <profile>
226           
227           <id>10_nexus</id>
228           <!--Enable snapshots for the built in central repo to direct -->
229           <!--all requests to nexus via the mirror -->
230           <repositories>
231               <repository>
232                   <id>10_nexus</id>
233                   <url>http://repo.maven.apache.org/maven2/</url>
234                   <releases><enabled>true</enabled></releases>
235                   <snapshots><enabled>true</enabled></snapshots>
236               </repository>
237           </repositories>
238           
239           <pluginRepositories>
240               <pluginRepository>
241                   <id>10_nexus</id>
242                   <url>http://repo.maven.apache.org/maven2/</url>
243                   <releases><enabled>true</enabled></releases>
244                   <snapshots><enabled>true</enabled></snapshots>
245               </pluginRepository>
246           </pluginRepositories>
247           
248       </profile>
249       <profile>
250           <id>20_openecomp-public</id>
251           <repositories>
252               <repository>
253                   <id>20_openecomp-public</id>
254                   <name>20_openecomp-public</name>
255                   <url>https://nexus.onap.org/content/repositories/public/</url>
256                   <releases>
257                       <enabled>true</enabled>
258                       <updatePolicy>daily</updatePolicy>
259                   </releases>
260                   <snapshots>
261                       <enabled>false</enabled>
262                   </snapshots>
263               </repository>
264           </repositories>
265           <pluginRepositories>
266               <pluginRepository>
267                   <id>20_openecomp-public</id>
268                   <name>20_openecomp-public</name>
269                   <url>https://nexus.onap.org/content/repositories/public/</url>
270                   <releases>
271                       <enabled>true</enabled>
272                       <updatePolicy>daily</updatePolicy>
273                   </releases>
274                   <snapshots>
275                       <enabled>false</enabled>
276                   </snapshots>
277               </pluginRepository>
278           </pluginRepositories>
279       </profile>
280       <profile>
281           <id>30_openecomp-staging</id>
282           <repositories>
283               <repository>
284                   <id>30_openecomp-staging</id>
285                   <name>30_openecomp-staging</name>
286                   <url>https://nexus.onap.org/content/repositories/staging/</url>
287                   <releases>
288                       <enabled>true</enabled>
289                       <updatePolicy>daily</updatePolicy>
290                   </releases>
291                   <snapshots>
292                       <enabled>false</enabled>
293                   </snapshots>
294               </repository>
295           </repositories>
296           <pluginRepositories>
297               <pluginRepository>
298                   <id>30_openecomp-staging</id>
299                   <name>30_openecomp-staging</name>
300                   <url>https://nexus.onap.org/content/repositories/staging/</url>
301                   <releases>
302                       <enabled>true</enabled>
303                       <updatePolicy>daily</updatePolicy>
304                   </releases>
305                   <snapshots>
306                       <enabled>false</enabled>
307                   </snapshots>
308               </pluginRepository>
309           </pluginRepositories>
310       </profile>
311       <profile>
312           <id>40_openecomp-release</id>
313           <repositories>
314               <repository>
315                   <id>40_openecomp-release</id>
316                   <name>40_openecomp-release</name>
317                   <url>https://nexus.onap.org/content/repositories/releases/</url>
318                   <releases>
319                       <enabled>true</enabled>
320                       <updatePolicy>daily</updatePolicy>
321                   </releases>
322                   <snapshots>
323                       <enabled>false</enabled>
324                   </snapshots>
325               </repository>
326           </repositories>
327           <pluginRepositories>
328               <pluginRepository>
329                   <id>40_openecomp-release</id>
330                   <name>40_openecomp-release</name>
331                   <url>https://nexus.onap.org/content/repositories/releases/</url>
332                   <releases>
333                       <enabled>true</enabled>
334                       <updatePolicy>daily</updatePolicy>
335                   </releases>
336                   <snapshots>
337                       <enabled>false</enabled>
338                   </snapshots>
339               </pluginRepository>
340           </pluginRepositories>
341       </profile>
342       
343       <profile>
344           <id>50_openecomp-snapshots</id>
345           <repositories>
346               <repository>
347                   <id>50_openecomp-snapshot</id>
348                   <name>50_openecomp-snapshot</name>
349                   <url>https://nexus.onap.org/content/repositories/snapshots/</url>
350                   <releases>
351                       <enabled>false</enabled>
352                   </releases>
353                   <snapshots>
354                       <enabled>true</enabled>
355                   </snapshots>
356               </repository>
357           </repositories>
358           <pluginRepositories>
359               <pluginRepository>
360                   <id>50_openecomp-snapshot</id>
361                   <name>50_openecomp-snapshot</name>
362                   <url>https://nexus.onap.org/content/repositories/snapshots/</url>
363                   <releases>
364                       <enabled>false</enabled>
365                   </releases>
366                   <snapshots>
367                       <enabled>true</enabled>
368                   </snapshots>
369               </pluginRepository>
370           </pluginRepositories>
371       </profile>
372       <profile>
373           <id>60_opendaylight-release</id>
374           <repositories>
375               <repository>
376                   <id>60_opendaylight-mirror</id>
377                   <name>60_opendaylight-mirror</name>
378                   <url>https://nexus.opendaylight.org/content/repositories/public/</url>
379                   <releases>
380                       <enabled>true</enabled>
381                       <updatePolicy>daily</updatePolicy>
382                   </releases>
383                   <snapshots>
384                       <enabled>false</enabled>
385                   </snapshots>
386               </repository>
387           </repositories>
388           <pluginRepositories>
389               <pluginRepository>
390                   <id>60_opendaylight-mirror</id>
391                   <name>60_opendaylight-mirror</name>
392                   <url>https://nexus.opendaylight.org/content/repositories/public/</url>
393                   <releases>
394                       <enabled>true</enabled>
395                       <updatePolicy>daily</updatePolicy>
396                   </releases>
397                   <snapshots>
398                       <enabled>false</enabled>
399                   </snapshots>
400               </pluginRepository>
401           </pluginRepositories>
402       </profile>
403       
404       <profile>
405           <id>70_opendaylight-snapshots</id>
406           <repositories>
407               <repository>
408                   <id>70_opendaylight-snapshot</id>
409                   <name>70_opendaylight-snapshot</name>
410                   <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
411                   <releases>
412                       <enabled>false</enabled>
413                   </releases>
414                   <snapshots>
415                       <enabled>true</enabled>
416                   </snapshots>
417               </repository>
418           </repositories>
419           <pluginRepositories>
420               <pluginRepository>
421                   <id>70_opendaylight-snapshot</id>
422                   <name>70_opendaylight-snapshot</name>
423                   <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
424                   <releases>
425                       <enabled>false</enabled>
426                   </releases>
427                   <snapshots>
428                       <enabled>true</enabled>
429                   </snapshots>
430               </pluginRepository>
431           </pluginRepositories>
432       </profile>
433   </profiles>
434   
435   <activeProfiles>
436       <activeProfile>10_nexus</activeProfile>
437       <activeProfile>20_openecomp-public</activeProfile>
438       <activeProfile>30_openecomp-staging</activeProfile>
439       <activeProfile>40_openecomp-release</activeProfile>
440       <activeProfile>50_openecomp-snapshots</activeProfile>
441       <activeProfile>60_opendaylight-release</activeProfile>
442       <activeProfile>70_opendaylight-snapshots</activeProfile>
443
444   </activeProfiles>
445   
446 </settings>
447 EOF
448
449 cd /opt/authz
450 mvn install -Dmaven.test.skip=true
451
452 cd /opt
453 ./aaf_vm_init.sh