blob: 52f1204984b8f725b8fd48c1a43fc8ee586a603c [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 Wu14a6b302018-05-01 15:59:28 -070035
36mkdir -p /dockerdata-nfs
Gary Wuad513722018-07-26 13:08:47 -070037echo "__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 -070038
Gary Wu1ff56672018-01-17 20:51:45 -080039# Fix virtual memory allocation for onap-log:elasticsearch:
40echo "vm.max_map_count=262144" >> /etc/sysctl.conf
41sysctl -p
42
Gary Wub0e36502018-10-16 11:01:07 -070043
44while ! hash jq &> /dev/null; do
45 apt-get -y update
46 apt-get -y install linux-image-extra-$(uname -r) jq nfs-common
47 sleep 10
48done
49
50# install docker 17.03
51while ! hash docker &> /dev/null; do
52 curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
53 usermod -aG docker ubuntu
54 sleep 10
55done
Gary Wu14a6b302018-05-01 15:59:28 -070056
57while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
58 mount /dockerdata-nfs
Gary Wub0e36502018-10-16 11:01:07 -070059 sleep 10
Gary Wuc98156d2018-01-18 12:03:26 -080060done
Gary Wub0e36502018-10-16 11:01:07 -070061
62cd ~
Gary Wu11c98742018-05-02 16:19:04 -070063cp /dockerdata-nfs/rancher_agent_cmd.sh .
64sed -i "s/docker run/docker run -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
65source rancher_agent_cmd.sh