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