f7866fdaadace02bd427fa758c897946322590e0
[demo.git] / heat / ONAP / cloud-config / dcae2_install.sh
1 #!/bin/bash
2 #############################################################################
3 #
4 # Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 #############################################################################
18
19 set -ex 
20
21 # add well-known DCAE hostname aliases
22 echo "$(cat /opt/config/dcae_ip_addr.txt) consul" >>/etc/hosts
23 echo "$(cat /opt/config/dcae_ip_addr.txt) dockerhost" >>/etc/hosts
24
25 # Read configuration files
26 EXTERNAL_DNS=$(cat /opt/config/external_dns.txt)
27 MAC_ADDR=$(cat /opt/config/mac_addr.txt)
28 HTTP_PROXY=$(cat /opt/config/http_proxy.txt)
29 HTTPS_PROXY=$(cat /opt/config/https_proxy.txt)
30
31 if [ $HTTP_PROXY != "no_proxy" ]
32 then
33     export http_proxy=$HTTP_PROXY
34     export https_proxy=$HTTPS_PROXY
35 fi
36
37
38 # Download dependencies
39 apt-get update
40 apt-get install -y python python-pip
41
42 # Download scripts from Nexus
43 cp /opt/boot/dcae2_vm_init.sh /opt/dcae2_vm_init.sh
44 chmod +x /opt/dcae2_vm_init.sh
45
46 DOCKER_OPTS=$(cat /etc/default/docker | grep ^DOCKER_OPTS)
47 DOCKER_OPTS=${DOCKER_OPTS::-1}" --raw-logs -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock\""
48 sed -i "s|DOCKER_OPTS=.*|DOCKER_OPTS=$DOCKER_OPTS|g" /etc/default/docker
49
50 #echo "DOCKER_OPTS=\" $DOCKER_OPTS --raw-logs -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock\" " >> /etc/default/docker
51 sed -i "/ExecStart/s/$/ -H tcp:\/\/0.0.0.0:2376 --raw-logs/g" /etc/systemd/system/docker.service
52 if [ ! -e /etc/docker/daemon.json ]; then
53   REGISTRY="$(cat /opt/config/nexus_docker_repo.txt)"
54   if [[ $REGISTRY != nexus3.onap.org* ]]; then
55     echo "{  \"insecure-registries\" : [\"${REGISTRY}\"] }" > /etc/docker/daemon.json
56   fi
57 fi
58 systemctl daemon-reload
59 service docker restart
60
61 # prepare the configurations needed by DCAEGEN2 installer
62 rm -rf /opt/app/config
63 mkdir -p /opt/app/config
64
65
66 cd /opt
67 ./dcae2_vm_init.sh &>/dev/null &disown