a4fd556a6c1a2c1874d45bb4deff90a47f8c1489
[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 update-rc.d dcae2_serv.sh defaults
42
43 echo "DOCKER_OPTS=\"\$DOCKER_OPTS --raw-logs -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock\"" >> /etc/default/docker
44 sed -i "/ExecStart/s/$/ -H tcp:\/\/0.0.0.0:2376 --raw-logs/g" /etc/systemd/system/docker.service
45 systemctl daemon-reload
46 service docker restart
47
48 # add hostname aliases
49 echo "$(cat /opt/config/dcae_ip_addr.txt) consul" >>/etc/hosts
50 echo "$(cat /opt/config/dcae_ip_addr.txt) dockerhost" >>/etc/hosts
51
52 # prepare the configurations needed by DCAEGEN2 installer
53 rm -rf /opt/app/config
54 mkdir -p /opt/app/config
55
56 # private key
57 sed -e 's/\\n/\n/g' /opt/config/priv_key | sed -e 's/^[ \t]*//g; s/[ \t]*$//g' > /opt/app/config/key
58 chmod 777 /opt/app/config/key
59
60 cd /opt
61 ./dcae2_vm_init.sh