blob: e93622cb3dad0247b7d79e69c8558cb5372cab58 [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 Wu3fd6c2a2018-10-28 21:44:00 -070012export DEBIAN_FRONTEND=noninteractive
Gary Wu895a4ac2018-10-31 12:30:54 -070013HOST_IP=$(hostname -I)
14echo $HOST_IP `hostname` >> /etc/hosts
Gary Wu1ff56672018-01-17 20:51:45 -080015printenv
16
17mkdir -p /opt/config
Gary Wu7a04b3d2018-08-15 12:31:46 -070018echo "__docker_version__" > /opt/config/docker_version.txt
Gary Wu1ff56672018-01-17 20:51:45 -080019echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
Gary Wuad513722018-07-26 13:08:47 -070020echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt
Gary Wu11c98742018-05-02 16:19:04 -070021
Gary Wu1ff56672018-01-17 20:51:45 -080022mkdir -p /etc/docker
Gary Wu374498a2018-02-06 17:31:04 -080023if [ ! -z "__docker_proxy__" ]; then
24 cat > /etc/docker/daemon.json <<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080025{
26 "insecure-registries" : ["__docker_proxy__"]
27}
28EOF
Gary Wu374498a2018-02-06 17:31:04 -080029fi
30if [ ! -z "__apt_proxy__" ]; then
31 cat > /etc/apt/apt.conf.d/30proxy<<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080032Acquire::http { Proxy "http://__apt_proxy__"; };
33Acquire::https::Proxy "DIRECT";
34EOF
Gary Wu374498a2018-02-06 17:31:04 -080035fi
Gary Wu14a6b302018-05-01 15:59:28 -070036
37mkdir -p /dockerdata-nfs
Determe, Sebastien (sd378r)bc0db3d2018-10-17 17:10:50 +020038echo "__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 -070039
Gary Wu675eb152018-10-26 10:50:27 -070040# workaround for OpenStack intermittent failure to change default apt mirrors
41sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
Gary Wub0e36502018-10-16 11:01:07 -070042
43while ! hash jq &> /dev/null; do
44 apt-get -y update
Gary Wu3fd6c2a2018-10-28 21:44:00 -070045 apt-get -y dist-upgrade
46 apt-get -y install linux-image-extra-$(uname -r) apt-transport-https ca-certificates curl software-properties-common jq nfs-common
Gary Wub0e36502018-10-16 11:01:07 -070047 sleep 10
48done
49
50# install docker 17.03
51while ! hash docker &> /dev/null; do
52 curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
53 usermod -aG docker ubuntu
54 sleep 10
55done
Gary Wu3fd6c2a2018-10-28 21:44:00 -070056apt-mark hold docker-ce
Gary Wu14a6b302018-05-01 15:59:28 -070057
58while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
59 mount /dockerdata-nfs
Gary Wub0e36502018-10-16 11:01:07 -070060 sleep 10
Gary Wuc98156d2018-01-18 12:03:26 -080061done
Gary Wub0e36502018-10-16 11:01:07 -070062
63cd ~
Gary Wu11c98742018-05-02 16:19:04 -070064cp /dockerdata-nfs/rancher_agent_cmd.sh .
Gary Wu3fd6c2a2018-10-28 21:44:00 -070065sed -i "s/docker run/docker run -e CATTLE_HOST_LABELS='__host_label__=true' -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
Gary Wu11c98742018-05-02 16:19:04 -070066source rancher_agent_cmd.sh
Gary Wu3fd6c2a2018-10-28 21:44:00 -070067sleep 1m
68
69reboot