blob: d8f833eed7ab54571500cb77adf8f74d3caa0e6e [file] [log] [blame]
Gary Wu950a3232019-03-26 13:08:29 -07001#!/bin/bash -x
2# 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#
10export DEBIAN_FRONTEND=noninteractive
11echo "__host_private_ip_addr__ $(hostname)" >> /etc/hosts
12printenv
13
14mkdir -p /opt/config
15echo "__docker_version__" > /opt/config/docker_version.txt
Gary Wud95bf2b2019-06-21 15:35:18 -070016echo "__nfs_ip_addr__" > /opt/config/nfs_ip_addr.txt
17echo "__nfs_private_ip_addr__" > /opt/config/nfs_private_ip_addr.txt
Gary Wu950a3232019-03-26 13:08:29 -070018echo "__host_private_ip_addr__" > /opt/config/host_private_ip_addr.txt
19echo "__mtu__" > /opt/config/mtu.txt
20
21mkdir -p /etc/docker
22if [ ! -z "__docker_proxy__" ]; then
23 cat > /etc/docker/daemon.json <<EOF
24{
25 "mtu": __mtu__,
26 "insecure-registries" : ["__docker_proxy__"]
27}
28EOF
29else
30 cat > /etc/docker/daemon.json <<EOF
31{
32 "mtu": __mtu__
33}
34EOF
35fi
36if [ ! -z "__apt_proxy__" ]; then
37 cat > /etc/apt/apt.conf.d/30proxy <<EOF
38Acquire::http { Proxy "http://__apt_proxy__"; };
39Acquire::https::Proxy "DIRECT";
40EOF
41fi
42
43
44mkdir -p /dockerdata-nfs
Gary Wud95bf2b2019-06-21 15:35:18 -070045echo "__nfs_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 Wu950a3232019-03-26 13:08:29 -070046
47# workaround for OpenStack intermittent failure to change default apt mirrors
48sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
49
50while ! hash jq &> /dev/null; do
51 apt-get -y update
52 # apt-get -y dist-upgrade
Gary Wu7ff8c6f2019-04-24 07:50:11 -070053 apt-get -y install curl jq nfs-common
54 sleep 10
55done
56
57# install docker
58while ! hash docker &> /dev/null; do
59 curl https://releases.rancher.com/install-docker/__docker_version__.sh | sh
Gary Wu950a3232019-03-26 13:08:29 -070060 systemctl enable docker
61 usermod -aG docker ubuntu
62 sleep 10
63done
64
65# Enable autorestart when VM reboots
66update-rc.d k8s_vm_init_serv defaults