Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # create_configuration_files() - Store credentials in files |
| 4 | function create_configuration_files { |
Victor Morales | 96fe388 | 2018-03-02 14:08:39 -0800 | [diff] [blame] | 5 | local onap_config_folder="/opt/config" |
| 6 | |
| 7 | mkdir -p $onap_config_folder |
| 8 | pushd $onap_config_folder |
| 9 | echo $nexus_docker_repo > nexus_docker_repo.txt |
| 10 | echo $nexus_username > nexus_username.txt |
| 11 | echo $nexus_password > nexus_password.txt |
| 12 | echo $openstack_username > openstack_username.txt |
| 13 | echo $openstack_tenant_id > tenant_id.txt |
| 14 | echo $dmaap_topic > dmaap_topic.txt |
| 15 | echo $docker_version > docker_version.txt |
| 16 | popd |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 17 | } |
| 18 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 19 | # docker_openecomp_login() - Login to OpenECOMP Docker Hub |
| 20 | function docker_openecomp_login { |
| 21 | install_docker |
Victor Morales | fa9eb9c | 2017-12-18 09:56:13 -0800 | [diff] [blame] | 22 | docker login -u ${nexus_username:-docker} -p ${nexus_password:-docker} ${nexus_docker_repo:-nexus3.onap.org:10001} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | # pull_openecomp_image() - Pull Docker container image from a Docker Registry Hub |
| 26 | function pull_openecomp_image { |
| 27 | local image=$1 |
| 28 | local tag=$2 |
| 29 | docker_openecomp_login |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 30 | pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/openecomp/${image}:${docker_version:-latest} $tag |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 31 | docker logout |
| 32 | } |
| 33 | |
Victor Morales | 896c807 | 2017-09-12 12:19:57 -0700 | [diff] [blame] | 34 | # pull_onap_image() - Pull Docker container image from a Docker Registry Hub |
| 35 | function pull_onap_image { |
| 36 | local image=$1 |
| 37 | local tag=$2 |
| 38 | docker_openecomp_login |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 39 | pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/onap/${image}:${docker_version:-latest} $tag |
Victor Morales | 896c807 | 2017-09-12 12:19:57 -0700 | [diff] [blame] | 40 | docker logout |
| 41 | } |
| 42 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 43 | # configure_bind()- Configure bind utils |
| 44 | function configure_bind { |
| 45 | _install_bind |
| 46 | mkdir /etc/bind/zones |
| 47 | |
| 48 | curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/db_simpledemo_openecomp_org -o /etc/bind/zones/db.simpledemo.openecomp.org |
| 49 | curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/named.conf.options -o /etc/bind/named.conf.options |
| 50 | curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/named.conf.local -o /etc/bind/named.conf.local |
| 51 | |
| 52 | modprobe ip_gre |
| 53 | sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9 |
| 54 | service bind9 restart |
| 55 | } |
| 56 | |
| 57 | # _configure_maven() - This function creates a maven configuration file in case that doesn't exist |
| 58 | function _configure_maven { |
| 59 | local proxies_start=" <!--" |
| 60 | local proxies=" \|" |
| 61 | local proxies_end=" \|-->" |
| 62 | local mvn_http="" |
| 63 | local mvn_https="" |
| 64 | |
| 65 | if [ $http_proxy ] | [ $https_proxy ]; then |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 66 | proxies_start=" <proxies>" |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 67 | proxies=" " |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 68 | proxies_end=" <\/proxies>" |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 69 | if [ $http_proxy ]; then |
| 70 | proxy_domain=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $1}'` |
| 71 | proxy_port=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $2}'` |
| 72 | 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>" |
| 73 | fi |
| 74 | if [ $https_proxy ]; then |
| 75 | proxy_domain=`echo $https_proxy | awk -F/ '{print $3}' | awk -F: '{print $1}'` |
| 76 | proxy_port=`echo $https_proxy | awk -F/ '{print $3}' | awk -F: '{print $2}'` |
| 77 | 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>" |
| 78 | fi |
| 79 | fi |
| 80 | |
Victor Morales | 1461312 | 2017-08-22 19:51:35 -0500 | [diff] [blame] | 81 | mkdir -p $(dirname $mvn_conf_file) |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 82 | if [ ! -f $mvn_conf_file ]; then |
Victor Morales | 2909e2e | 2017-08-08 15:51:52 -0500 | [diff] [blame] | 83 | if [[ "$enable_oparent" == "True" ]]; then |
| 84 | clone_repo oparent |
| 85 | cp $git_src_folder/oparent/settings.xml $mvn_conf_file |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 86 | sed -i "s|<\/profiles>|<\/profiles>\n%PROXIES_START%\n%PROXIES% %HTTP_PROXY%\n%PROXIES% %HTTPS_PROXY%\n%PROXIES_END%|g" $mvn_conf_file |
Victor Morales | 2909e2e | 2017-08-08 15:51:52 -0500 | [diff] [blame] | 87 | else |
| 88 | cp /var/onap/files/settings.xml $mvn_conf_file |
| 89 | fi |
| 90 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 91 | sed -e " |
| 92 | s|%PROXIES_START%|$proxies_start|g; |
| 93 | s|%PROXIES%|$proxies|g; |
| 94 | s|%HTTP_PROXY%|$mvn_http|g; |
| 95 | s|%HTTPS_PROXY%|$mvn_https|g; |
| 96 | s|%PROXIES_END%|$proxies_end|g |
| 97 | " -i $mvn_conf_file |
| 98 | fi |
| 99 | } |
| 100 | |
| 101 | # configure_service() - Download and configure a specific service in upstart |
| 102 | function configure_service { |
| 103 | local service_script=$1 |
| 104 | curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/$service_script -o /etc/init.d/$service_script |
| 105 | chmod +x /etc/init.d/$service_script |
| 106 | update-rc.d $service_script defaults |
| 107 | } |