fbc8db3c43ee49f3eff23ff84d0610c28b6f2a95
[demo.git] / heat / ONAP / cloud-config / dcae2_install.sh
1 #!/bin/bash
2 #############################################################################
3 #
4 # Copyright (c) 2017 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 # Read configuration files
22 EXTERNAL_DNS=$(cat /opt/config/external_dns.txt)
23 MAC_ADDR=$(cat /opt/config/mac_addr.txt)
24 HTTP_PROXY=$(cat /opt/config/http_proxy.txt)
25 HTTPS_PROXY=$(cat /opt/config/https_proxy.txt)
26
27 if [ $HTTP_PROXY != "no_proxy" ]
28 then
29     export http_proxy=$HTTP_PROXY
30     export https_proxy=$HTTPS_PROXY
31 fi
32
33
34 # Download dependencies
35 apt-get update
36 apt-get install -y python python-pip
37
38 # Download scripts from Nexus
39 cp /opt/boot/dcae2_vm_init.sh /opt/dcae2_vm_init.sh
40 chmod +x /opt/dcae2_vm_init.sh
41
42 echo "DOCKER_OPTS=\"\$DOCKER_OPTS --raw-logs -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock\"" >> /etc/default/docker
43 sed -i "/ExecStart/s/$/ -H tcp:\/\/0.0.0.0:2376 --raw-logs/g" /etc/systemd/system/docker.service
44 systemctl daemon-reload
45 service docker restart
46
47 # add hostname aliases
48 echo "$(cat /opt/config/dcae_ip_addr.txt) consul" >>/etc/hosts
49 echo "$(cat /opt/config/dcae_ip_addr.txt) dockerhost" >>/etc/hosts
50
51 # prepare the configurations needed by DCAEGEN2 installer
52 rm -rf /opt/app/config
53 mkdir -p /opt/app/config
54
55 # private key
56 sed -e 's/\\n/\n/g' /opt/config/priv_key | sed -e 's/^[ \t]*//g; s/[ \t]*$//g' > /opt/app/config/key
57 chmod 777 /opt/app/config/key
58
59 cd /opt
60 ./dcae2_vm_init.sh