blob: 6311dfbff7279bc29344763c9fe4ed3e1d9c8587 [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
Determe, Sebastien (sd378r)bc0db3d2018-10-17 17:10:50 +020037echo "__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
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 Wu675eb152018-10-26 10:50:27 -070043# workaround for OpenStack intermittent failure to change default apt mirrors
44sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
Gary Wub0e36502018-10-16 11:01:07 -070045
46while ! hash jq &> /dev/null; do
47 apt-get -y update
Gary Wu675eb152018-10-26 10:50:27 -070048 apt-get -y install apt-transport-https ca-certificates curl software-properties-common linux-image-extra-$(uname -r) jq nfs-common
Gary Wub0e36502018-10-16 11:01:07 -070049 sleep 10
50done
51
52# install docker 17.03
53while ! hash docker &> /dev/null; do
54 curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
55 usermod -aG docker ubuntu
56 sleep 10
57done
Gary Wu14a6b302018-05-01 15:59:28 -070058
59while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
60 mount /dockerdata-nfs
Gary Wub0e36502018-10-16 11:01:07 -070061 sleep 10
Gary Wuc98156d2018-01-18 12:03:26 -080062done
Gary Wub0e36502018-10-16 11:01:07 -070063
64cd ~
Gary Wu11c98742018-05-02 16:19:04 -070065cp /dockerdata-nfs/rancher_agent_cmd.sh .
66sed -i "s/docker run/docker run -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
67source rancher_agent_cmd.sh