blob: 11d8057991a3e883ed950beb9a029f3438eb8b27 [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 Wuad513722018-07-26 13:08:47 -070016echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt
Gary Wu11c98742018-05-02 16:19:04 -070017HOST_IP=$(hostname -I)
18echo $HOST_IP `hostname` >> /etc/hosts
19
Gary Wu1ff56672018-01-17 20:51:45 -080020mkdir -p /etc/docker
Gary Wu374498a2018-02-06 17:31:04 -080021if [ ! -z "__docker_proxy__" ]; then
22 cat > /etc/docker/daemon.json <<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080023{
24 "insecure-registries" : ["__docker_proxy__"]
25}
26EOF
Gary Wu374498a2018-02-06 17:31:04 -080027fi
28if [ ! -z "__apt_proxy__" ]; then
29 cat > /etc/apt/apt.conf.d/30proxy<<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080030Acquire::http { Proxy "http://__apt_proxy__"; };
31Acquire::https::Proxy "DIRECT";
32EOF
Gary Wu374498a2018-02-06 17:31:04 -080033fi
Gary Wu1ff56672018-01-17 20:51:45 -080034apt-get -y update
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
39apt-get -y install linux-image-extra-$(uname -r) jq nfs-common
Gary Wu1ff56672018-01-17 20:51:45 -080040
41cd ~
42
Gary Wu57abb1a2018-03-09 13:38:28 -080043# install docker 17.03
44curl -s https://releases.rancher.com/install-docker/17.03.sh | sh
Gary Wu1ff56672018-01-17 20:51:45 -080045usermod -aG docker ubuntu
46
Gary Wu1ff56672018-01-17 20:51:45 -080047# Fix virtual memory allocation for onap-log:elasticsearch:
48echo "vm.max_map_count=262144" >> /etc/sysctl.conf
49sysctl -p
50
Gary Wuc98156d2018-01-18 12:03:26 -080051sleep 100
Gary Wu14a6b302018-05-01 15:59:28 -070052
53while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
54 mount /dockerdata-nfs
55 sleep 5
Gary Wuc98156d2018-01-18 12:03:26 -080056done
Gary Wu11c98742018-05-02 16:19:04 -070057cp /dockerdata-nfs/rancher_agent_cmd.sh .
58sed -i "s/docker run/docker run -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
59source rancher_agent_cmd.sh