blob: f68d6dbf04ce80d8482a389d6e1037d458dae4af [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
3# create_configuration_files() - Store credentials in files
4function create_configuration_files {
5 mkdir -p /opt/config
6 echo $nexus_docker_repo > /opt/config/nexus_docker_repo.txt
7 echo $nexus_username > /opt/config/nexus_username.txt
8 echo $nexus_password > /opt/config/nexus_password.txt
9 echo $openstack_username > /opt/config/openstack_username.txt
10 echo $openstack_tenant_id > /opt/config/tenant_id.txt
11 echo $dmaap_topic > /opt/config/dmaap_topic.txt
12 echo $docker_version > /opt/config/docker_version.txt
13}
14
Victor Moralesdd074802017-07-26 16:06:35 -050015# docker_openecomp_login() - Login to OpenECOMP Docker Hub
16function docker_openecomp_login {
17 install_docker
Victor Moralesfa9eb9c2017-12-18 09:56:13 -080018 docker login -u ${nexus_username:-docker} -p ${nexus_password:-docker} ${nexus_docker_repo:-nexus3.onap.org:10001}
Victor Moralesdd074802017-07-26 16:06:35 -050019}
20
21# pull_openecomp_image() - Pull Docker container image from a Docker Registry Hub
22function pull_openecomp_image {
23 local image=$1
24 local tag=$2
25 docker_openecomp_login
Victor Moralesbe844712018-01-22 10:07:28 -080026 pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/openecomp/${image}:${docker_version:-latest} $tag
Victor Moralesdd074802017-07-26 16:06:35 -050027 docker logout
28}
29
Victor Morales896c8072017-09-12 12:19:57 -070030# pull_onap_image() - Pull Docker container image from a Docker Registry Hub
31function pull_onap_image {
32 local image=$1
33 local tag=$2
34 docker_openecomp_login
Victor Moralesbe844712018-01-22 10:07:28 -080035 pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/onap/${image}:${docker_version:-latest} $tag
Victor Morales896c8072017-09-12 12:19:57 -070036 docker logout
37}
38
Victor Moralesdd074802017-07-26 16:06:35 -050039# configure_bind()- Configure bind utils
40function configure_bind {
41 _install_bind
42 mkdir /etc/bind/zones
43
44 curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/db_simpledemo_openecomp_org -o /etc/bind/zones/db.simpledemo.openecomp.org
45 curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/named.conf.options -o /etc/bind/named.conf.options
46 curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/named.conf.local -o /etc/bind/named.conf.local
47
48 modprobe ip_gre
49 sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9
50 service bind9 restart
51}
52
53# _configure_maven() - This function creates a maven configuration file in case that doesn't exist
54function _configure_maven {
55 local proxies_start=" <!--"
56 local proxies=" \|"
57 local proxies_end=" \|-->"
58 local mvn_http=""
59 local mvn_https=""
60
61 if [ $http_proxy ] | [ $https_proxy ]; then
Victor Morales20163062017-08-09 10:50:44 -050062 proxies_start=" <proxies>"
Victor Moralesdd074802017-07-26 16:06:35 -050063 proxies=" "
Victor Morales20163062017-08-09 10:50:44 -050064 proxies_end=" <\/proxies>"
Victor Moralesdd074802017-07-26 16:06:35 -050065 if [ $http_proxy ]; then
66 proxy_domain=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $1}'`
67 proxy_port=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $2}'`
68 mvn_http="<proxy>\n <id>http</id>\n <active>true</active>\n <protocol>http</protocol>\n <host>$proxy_domain</host>\n <port>$proxy_port</port>\n <nonProxyHosts>${no_proxy}</nonProxyHosts>\n </proxy>"
69 fi
70 if [ $https_proxy ]; then
71 proxy_domain=`echo $https_proxy | awk -F/ '{print $3}' | awk -F: '{print $1}'`
72 proxy_port=`echo $https_proxy | awk -F/ '{print $3}' | awk -F: '{print $2}'`
73 mvn_https="<proxy>\n <id>https</id>\n <active>true</active>\n <protocol>https</protocol>\n <host>$proxy_domain</host>\n <port>$proxy_port</port>\n <nonProxyHosts>${no_proxy}</nonProxyHosts>\n </proxy>"
74 fi
75 fi
76
Victor Morales14613122017-08-22 19:51:35 -050077 mkdir -p $(dirname $mvn_conf_file)
Victor Moralesdd074802017-07-26 16:06:35 -050078 if [ ! -f $mvn_conf_file ]; then
Victor Morales2909e2e2017-08-08 15:51:52 -050079 if [[ "$enable_oparent" == "True" ]]; then
80 clone_repo oparent
81 cp $git_src_folder/oparent/settings.xml $mvn_conf_file
Victor Morales20163062017-08-09 10:50:44 -050082 sed -i "s|<\/profiles>|<\/profiles>\n%PROXIES_START%\n%PROXIES% %HTTP_PROXY%\n%PROXIES% %HTTPS_PROXY%\n%PROXIES_END%|g" $mvn_conf_file
Victor Morales2909e2e2017-08-08 15:51:52 -050083 else
84 cp /var/onap/files/settings.xml $mvn_conf_file
85 fi
86
Victor Moralesdd074802017-07-26 16:06:35 -050087 sed -e "
88 s|%PROXIES_START%|$proxies_start|g;
89 s|%PROXIES%|$proxies|g;
90 s|%HTTP_PROXY%|$mvn_http|g;
91 s|%HTTPS_PROXY%|$mvn_https|g;
92 s|%PROXIES_END%|$proxies_end|g
93 " -i $mvn_conf_file
94 fi
95}
96
97# configure_service() - Download and configure a specific service in upstart
98function configure_service {
99 local service_script=$1
100 curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/$service_script -o /etc/init.d/$service_script
101 chmod +x /etc/init.d/$service_script
102 update-rc.d $service_script defaults
103}