Adaptation of PnP PNF simulator heat template
[integration.git] / deployment / heat / onap-oom / k8s_vm_entrypoint.sh
1 #!/bin/bash -x
2 #
3 # Copyright 2018 Huawei Technologies Co., Ltd.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11
12 export DEBIAN_FRONTEND=noninteractive
13 HOST_IP=$(hostname -I)
14 echo $HOST_IP `hostname` >> /etc/hosts
15 printenv
16
17 mkdir -p /opt/config
18 echo "__docker_version__" > /opt/config/docker_version.txt
19 echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
20 echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt
21
22 mkdir -p /etc/docker
23 if [ ! -z "__docker_proxy__" ]; then
24     cat > /etc/docker/daemon.json <<EOF
25 {
26   "insecure-registries" : ["__docker_proxy__"]
27 }
28 EOF
29 fi
30 if [ ! -z "__apt_proxy__" ]; then
31     cat > /etc/apt/apt.conf.d/30proxy<<EOF
32 Acquire::http { Proxy "http://__apt_proxy__"; };
33 Acquire::https::Proxy "DIRECT";
34 EOF
35 fi
36
37 # tune ext4 for performance
38 sed -i 's/defaults/defaults,noatime,commit=60,barrier=0/' /etc/fstab
39
40 mkdir -p /dockerdata-nfs
41 echo "__rancher_private_ip_addr__:/dockerdata-nfs /dockerdata-nfs nfs noauto,noatime,fg,retry=1,x-systemd.automount,_netdev,soft,nolock,intr,tcp,actimeo=1800 0 0" | tee -a /etc/fstab
42
43 # workaround for OpenStack intermittent failure to change default apt mirrors
44 sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
45
46 while ! hash jq &> /dev/null; do
47     apt-get -y update
48     apt-get -y dist-upgrade
49     apt-get -y install linux-image-extra-$(uname -r) apt-transport-https ca-certificates curl software-properties-common jq nfs-common
50     sleep 10
51 done
52
53 # install docker 17.03
54 while ! hash docker &> /dev/null; do
55     curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
56     usermod -aG docker ubuntu
57     sleep 10
58 done
59 apt-mark hold docker-ce
60
61 while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
62     mount /dockerdata-nfs
63     sleep 10
64 done
65
66 cd ~
67 cp /dockerdata-nfs/rancher_agent_cmd.sh .
68 sed -i "s/docker run/docker run -e CATTLE_HOST_LABELS='__host_label__=true' -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
69 source rancher_agent_cmd.sh
70 sleep 1m
71
72 reboot