Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 1 | #!/bin/bash -x |
Gary Wu | a3fb86f | 2018-06-04 16:23:54 -0700 | [diff] [blame] | 2 | # |
| 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 Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 12 | printenv |
| 13 | |
| 14 | mkdir -p /opt/config |
| 15 | echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 16 | echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 17 | HOST_IP=$(hostname -I) |
| 18 | echo $HOST_IP `hostname` >> /etc/hosts |
| 19 | |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 20 | mkdir -p /etc/docker |
Gary Wu | 374498a | 2018-02-06 17:31:04 -0800 | [diff] [blame] | 21 | if [ ! -z "__docker_proxy__" ]; then |
| 22 | cat > /etc/docker/daemon.json <<EOF |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 23 | { |
| 24 | "insecure-registries" : ["__docker_proxy__"] |
| 25 | } |
| 26 | EOF |
Gary Wu | 374498a | 2018-02-06 17:31:04 -0800 | [diff] [blame] | 27 | fi |
| 28 | if [ ! -z "__apt_proxy__" ]; then |
| 29 | cat > /etc/apt/apt.conf.d/30proxy<<EOF |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 30 | Acquire::http { Proxy "http://__apt_proxy__"; }; |
| 31 | Acquire::https::Proxy "DIRECT"; |
| 32 | EOF |
Gary Wu | 374498a | 2018-02-06 17:31:04 -0800 | [diff] [blame] | 33 | fi |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 34 | apt-get -y update |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 35 | |
| 36 | mkdir -p /dockerdata-nfs |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 37 | echo "__rancher_private_ip_addr__:/dockerdata-nfs /dockerdata-nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0" | tee -a /etc/fstab |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 38 | |
| 39 | apt-get -y install linux-image-extra-$(uname -r) jq nfs-common |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 40 | |
| 41 | cd ~ |
| 42 | |
Gary Wu | 57abb1a | 2018-03-09 13:38:28 -0800 | [diff] [blame] | 43 | # install docker 17.03 |
| 44 | curl -s https://releases.rancher.com/install-docker/17.03.sh | sh |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 45 | usermod -aG docker ubuntu |
| 46 | |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 47 | # Fix virtual memory allocation for onap-log:elasticsearch: |
| 48 | echo "vm.max_map_count=262144" >> /etc/sysctl.conf |
| 49 | sysctl -p |
| 50 | |
Gary Wu | c98156d | 2018-01-18 12:03:26 -0800 | [diff] [blame] | 51 | sleep 100 |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 52 | |
| 53 | while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do |
| 54 | mount /dockerdata-nfs |
| 55 | sleep 5 |
Gary Wu | c98156d | 2018-01-18 12:03:26 -0800 | [diff] [blame] | 56 | done |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 57 | cp /dockerdata-nfs/rancher_agent_cmd.sh . |
| 58 | sed -i "s/docker run/docker run -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh |
| 59 | source rancher_agent_cmd.sh |