blob: 3e80f8ea0a42a05e0a2e5d0ea4d679eeb474b28b [file] [log] [blame]
Gary Wu1ff56672018-01-17 20:51:45 -08001#!/bin/bash -x
Gary Wua3fb86f2018-06-04 16:23:54 -07002# Copyright 2018 Huawei Technologies Co., Ltd.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
Gary Wu3fd6c2a2018-10-28 21:44:00 -070010export DEBIAN_FRONTEND=noninteractive
Gary Wub7189982018-11-14 10:01:37 -080011echo "__host_private_ip_addr__ $(hostname)" >> /etc/hosts
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 Wub7189982018-11-14 10:01:37 -080018echo "__host_private_ip_addr__" > /opt/config/host_private_ip_addr.txt
Gary Wub8be70a2018-11-17 17:14:38 -080019echo "__mtu__" > /opt/config/mtu.txt
Gary Wu11c98742018-05-02 16:19:04 -070020
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{
Gary Wub8be70a2018-11-17 17:14:38 -080025 "mtu": __mtu__,
Gary Wu1ff56672018-01-17 20:51:45 -080026 "insecure-registries" : ["__docker_proxy__"]
27}
28EOF
Gary Wub8be70a2018-11-17 17:14:38 -080029else
30 cat > /etc/docker/daemon.json <<EOF
31{
32 "mtu": __mtu__
33}
34EOF
Gary Wu374498a2018-02-06 17:31:04 -080035fi
36if [ ! -z "__apt_proxy__" ]; then
Gary Wub7189982018-11-14 10:01:37 -080037 cat > /etc/apt/apt.conf.d/30proxy <<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080038Acquire::http { Proxy "http://__apt_proxy__"; };
39Acquire::https::Proxy "DIRECT";
40EOF
Gary Wu374498a2018-02-06 17:31:04 -080041fi
Gary Wu14a6b302018-05-01 15:59:28 -070042
Gary Wu48a32942018-11-08 07:34:49 -080043# tune ext4 for performance
44sed -i 's/defaults/defaults,noatime,commit=60,barrier=0/' /etc/fstab
45
Gary Wu14a6b302018-05-01 15:59:28 -070046mkdir -p /dockerdata-nfs
Determe, Sebastien (sd378r)bc0db3d2018-10-17 17:10:50 +020047echo "__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 -070048
Gary Wu675eb152018-10-26 10:50:27 -070049# workaround for OpenStack intermittent failure to change default apt mirrors
50sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
Gary Wub0e36502018-10-16 11:01:07 -070051
52while ! hash jq &> /dev/null; do
53 apt-get -y update
Gary Wu3fd6c2a2018-10-28 21:44:00 -070054 apt-get -y dist-upgrade
55 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 -070056 sleep 10
57done
58
59# install docker 17.03
60while ! hash docker &> /dev/null; do
61 curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
62 usermod -aG docker ubuntu
63 sleep 10
64done
Gary Wu3fd6c2a2018-10-28 21:44:00 -070065apt-mark hold docker-ce
Gary Wu14a6b302018-05-01 15:59:28 -070066
Gary Wub7189982018-11-14 10:01:37 -080067# Enable autorestart when VM reboots
68update-rc.d k8s_vm_init_serv defaults