blob: 54a674125af5470f2ed0c54c2e3ee7066f50b73e [file] [log] [blame]
Gary Wu1ff56672018-01-17 20:51:45 -08001#!/bin/bash -x
Gary Wua3fb86f2018-06-04 16:23:54 -07002#
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
Gary Wu1ff56672018-01-17 20:51:45 -080012printenv
13
14mkdir -p /opt/config
Gary Wu7a04b3d2018-08-15 12:31:46 -070015echo "__docker_version__" > /opt/config/docker_version.txt
Gary Wu1ff56672018-01-17 20:51:45 -080016echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
Gary Wuad513722018-07-26 13:08:47 -070017echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt
Gary Wu11c98742018-05-02 16:19:04 -070018HOST_IP=$(hostname -I)
19echo $HOST_IP `hostname` >> /etc/hosts
20
Gary Wu1ff56672018-01-17 20:51:45 -080021mkdir -p /etc/docker
Gary Wu374498a2018-02-06 17:31:04 -080022if [ ! -z "__docker_proxy__" ]; then
23 cat > /etc/docker/daemon.json <<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080024{
25 "insecure-registries" : ["__docker_proxy__"]
26}
27EOF
Gary Wu374498a2018-02-06 17:31:04 -080028fi
29if [ ! -z "__apt_proxy__" ]; then
30 cat > /etc/apt/apt.conf.d/30proxy<<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080031Acquire::http { Proxy "http://__apt_proxy__"; };
32Acquire::https::Proxy "DIRECT";
33EOF
Gary Wu374498a2018-02-06 17:31:04 -080034fi
Gary Wu1ff56672018-01-17 20:51:45 -080035apt-get -y update
Gary Wu14a6b302018-05-01 15:59:28 -070036
37mkdir -p /dockerdata-nfs
Gary Wuad513722018-07-26 13:08:47 -070038echo "__rancher_private_ip_addr__:/dockerdata-nfs /dockerdata-nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0" | tee -a /etc/fstab
Gary Wu14a6b302018-05-01 15:59:28 -070039
40apt-get -y install linux-image-extra-$(uname -r) jq nfs-common
Gary Wu1ff56672018-01-17 20:51:45 -080041
42cd ~
43
Gary Wu57abb1a2018-03-09 13:38:28 -080044# install docker 17.03
Gary Wu7a04b3d2018-08-15 12:31:46 -070045curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
Gary Wu1ff56672018-01-17 20:51:45 -080046usermod -aG docker ubuntu
47
Gary Wu1ff56672018-01-17 20:51:45 -080048# Fix virtual memory allocation for onap-log:elasticsearch:
49echo "vm.max_map_count=262144" >> /etc/sysctl.conf
50sysctl -p
51
Gary Wuc98156d2018-01-18 12:03:26 -080052sleep 100
Gary Wu14a6b302018-05-01 15:59:28 -070053
54while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
55 mount /dockerdata-nfs
56 sleep 5
Gary Wuc98156d2018-01-18 12:03:26 -080057done
Gary Wu11c98742018-05-02 16:19:04 -070058cp /dockerdata-nfs/rancher_agent_cmd.sh .
59sed -i "s/docker run/docker run -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
60source rancher_agent_cmd.sh