blob: a6392354c5759d30a1f0fb830f29bec167a0dc5a [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
15echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
Gary Wu11c98742018-05-02 16:19:04 -070016HOST_IP=$(hostname -I)
17echo $HOST_IP `hostname` >> /etc/hosts
18
Gary Wu1ff56672018-01-17 20:51:45 -080019mkdir -p /etc/docker
Gary Wu374498a2018-02-06 17:31:04 -080020if [ ! -z "__docker_proxy__" ]; then
21 cat > /etc/docker/daemon.json <<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080022{
23 "insecure-registries" : ["__docker_proxy__"]
24}
25EOF
Gary Wu374498a2018-02-06 17:31:04 -080026fi
27if [ ! -z "__apt_proxy__" ]; then
28 cat > /etc/apt/apt.conf.d/30proxy<<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080029Acquire::http { Proxy "http://__apt_proxy__"; };
30Acquire::https::Proxy "DIRECT";
31EOF
Gary Wu374498a2018-02-06 17:31:04 -080032fi
Gary Wu1ff56672018-01-17 20:51:45 -080033apt-get -y update
Gary Wu14a6b302018-05-01 15:59:28 -070034
35mkdir -p /dockerdata-nfs
36echo "__rancher_ip_addr__:/dockerdata-nfs /dockerdata-nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0" | tee -a /etc/fstab
37
38apt-get -y install linux-image-extra-$(uname -r) jq nfs-common
Gary Wu1ff56672018-01-17 20:51:45 -080039
40cd ~
41
Gary Wu57abb1a2018-03-09 13:38:28 -080042# install docker 17.03
43curl -s https://releases.rancher.com/install-docker/17.03.sh | sh
Gary Wu1ff56672018-01-17 20:51:45 -080044usermod -aG docker ubuntu
45
Gary Wu1ff56672018-01-17 20:51:45 -080046# Fix virtual memory allocation for onap-log:elasticsearch:
47echo "vm.max_map_count=262144" >> /etc/sysctl.conf
48sysctl -p
49
Gary Wuc98156d2018-01-18 12:03:26 -080050sleep 100
Gary Wu14a6b302018-05-01 15:59:28 -070051
52while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
53 mount /dockerdata-nfs
54 sleep 5
Gary Wuc98156d2018-01-18 12:03:26 -080055done
Gary Wu11c98742018-05-02 16:19:04 -070056cp /dockerdata-nfs/rancher_agent_cmd.sh .
57sed -i "s/docker run/docker run -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
58source rancher_agent_cmd.sh