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