blob: e5b843e5d293bf1797d024e7b6f9a1ea0d06d646 [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 Wu11c98742018-05-02 16:19:04 -070019
Gary Wu1ff56672018-01-17 20:51:45 -080020mkdir -p /etc/docker
Gary Wu374498a2018-02-06 17:31:04 -080021if [ ! -z "__docker_proxy__" ]; then
22 cat > /etc/docker/daemon.json <<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080023{
24 "insecure-registries" : ["__docker_proxy__"]
25}
26EOF
Gary Wu374498a2018-02-06 17:31:04 -080027fi
28if [ ! -z "__apt_proxy__" ]; then
Gary Wub7189982018-11-14 10:01:37 -080029 cat > /etc/apt/apt.conf.d/30proxy <<EOF
Gary Wu1ff56672018-01-17 20:51:45 -080030Acquire::http { Proxy "http://__apt_proxy__"; };
31Acquire::https::Proxy "DIRECT";
32EOF
Gary Wu374498a2018-02-06 17:31:04 -080033fi
Gary Wu14a6b302018-05-01 15:59:28 -070034
Gary Wu48a32942018-11-08 07:34:49 -080035# tune ext4 for performance
36sed -i 's/defaults/defaults,noatime,commit=60,barrier=0/' /etc/fstab
37
Gary Wu14a6b302018-05-01 15:59:28 -070038mkdir -p /dockerdata-nfs
Determe, Sebastien (sd378r)bc0db3d2018-10-17 17:10:50 +020039echo "__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 -070040
Gary Wu675eb152018-10-26 10:50:27 -070041# workaround for OpenStack intermittent failure to change default apt mirrors
42sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
Gary Wub0e36502018-10-16 11:01:07 -070043
44while ! hash jq &> /dev/null; do
45 apt-get -y update
Gary Wu3fd6c2a2018-10-28 21:44:00 -070046 apt-get -y dist-upgrade
47 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 -070048 sleep 10
49done
50
51# install docker 17.03
52while ! hash docker &> /dev/null; do
53 curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
54 usermod -aG docker ubuntu
55 sleep 10
56done
Gary Wu3fd6c2a2018-10-28 21:44:00 -070057apt-mark hold docker-ce
Gary Wu14a6b302018-05-01 15:59:28 -070058
Gary Wub7189982018-11-14 10:01:37 -080059# Enable autorestart when VM reboots
60update-rc.d k8s_vm_init_serv defaults