2 # Copyright 2018 Huawei Technologies Co., Ltd.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
10 export DEBIAN_FRONTEND=noninteractive
11 echo "__host_private_ip_addr__ $(hostname)" >> /etc/hosts
15 echo "__docker_version__" > /opt/config/docker_version.txt
16 echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
17 echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt
18 echo "__host_private_ip_addr__" > /opt/config/host_private_ip_addr.txt
19 echo "__mtu__" > /opt/config/mtu.txt
22 if [ ! -z "__docker_proxy__" ]; then
23 cat > /etc/docker/daemon.json <<EOF
26 "insecure-registries" : ["__docker_proxy__"]
30 cat > /etc/docker/daemon.json <<EOF
36 if [ ! -z "__apt_proxy__" ]; then
37 cat > /etc/apt/apt.conf.d/30proxy <<EOF
38 Acquire::http { Proxy "http://__apt_proxy__"; };
39 Acquire::https::Proxy "DIRECT";
43 # tune ext4 for performance
44 sed -i 's/defaults/defaults,noatime,commit=60,barrier=0/' /etc/fstab
46 mkdir -p /dockerdata-nfs
47 echo "__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
49 # workaround for OpenStack intermittent failure to change default apt mirrors
50 sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
52 while ! hash jq &> /dev/null; do
54 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
59 # install docker 17.03
60 while ! hash docker &> /dev/null; do
61 curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
62 usermod -aG docker ubuntu
65 apt-mark hold docker-ce
67 # Enable autorestart when VM reboots
68 update-rc.d k8s_vm_init_serv defaults