blob: 1487f4209138dfecca86b4ac7c718fa53b9f5b1b [file] [log] [blame]
Richard Felkld59c5652018-02-08 13:14:05 +01001#!/bin/bash -xe
azvyagintsev6d453852018-02-26 16:56:37 +02002
3UBUNTU_BASEURL="${UBUNTU_BASEURL:-"mirror://mirrors.ubuntu.com/mirrors.txt"}"
4
Richard Felkld59c5652018-02-08 13:14:05 +01005## Base packages and setup
6export DEBIAN_FRONTEND=noninteractive
7echo "exit 101" > /usr/sbin/policy-rc.d
8chmod +x /usr/sbin/policy-rc.d
9
10echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
azvyagintsev6d453852018-02-26 16:56:37 +020011echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
Richard Felkld59c5652018-02-08 13:14:05 +010012
azvyagintsev6d453852018-02-26 16:56:37 +020013sysctl -w fs.file-max=100000
Richard Felkld59c5652018-02-08 13:14:05 +010014# Overwrite default mirrors
azvyagintsev6d453852018-02-26 16:56:37 +020015echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted multiverse universe" > /etc/apt/sources.list
16echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list
17echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted multiverse universe" >> /etc/apt/sources.list
18#echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-backports main restricted multiverse universe" >> /etc/apt/sources.list
Richard Felkld59c5652018-02-08 13:14:05 +010019
20apt-get clean
21apt-get update
22
23# Useful tools
24apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget
25# Install common prerequisites
26apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil
27
28# Cleanup old kernels, ensure latest is installed via virtual package
Richard Felkld59c5652018-02-08 13:14:05 +010029if [ ! -f /tmp/no_install_kernel ]; then
azvyagintsev6d453852018-02-26 16:56:37 +020030 apt-get purge -y linux-image-* linux-headers-*
31 apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial
Richard Felkld59c5652018-02-08 13:14:05 +010032
33 # Update grub cmdline
34 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
35 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
36 update-grub
37fi
38
39apt-get -y upgrade
40apt-get -y dist-upgrade
41
42apt-get autoremove --purge
43
44# Tmux fixes
45cat << 'EOF' >> /etc/tmux.conf
46set -g default-terminal "screen-256color"
47set -g set-titles on
48set -g xterm-keys on
49EOF
50
51# Setup cloud-init
52apt-get -y install cloud-init
53
54# Disable apt-daily
55systemctl disable apt-daily.timer
56
57# Motd
58apt-get -y install update-motd
59rm -vf /etc/update-motd.d/*
60echo "BUILD_TIMESTAMP=$(date '+%Y-%m-%d-%H-%M-%S' -u)" > /etc/image_version
61echo "BUILD_TIMESTAMP_RFC=\"$(date -u -R)\"" >> /etc/image_version
62cat << 'EOF' >> /etc/update-motd.d/00-header-mirantis
63#!/bin/sh
64#
65# 00-header - create the header of the MOTD
66#
67[ -r /etc/image_version ] && . /etc/image_version
68echo "Ubuntu 16.04 \"Xenial\" Mirantis cloud image"
69echo "Build date: ${BUILD_TIMESTAMP_RFC}"
70EOF
71chmod +x /etc/update-motd.d/00-header-mirantis
72