Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame^] | 1 | #!/bin/bash -xe |
| 2 | ## Base packages and setup |
| 3 | export DEBIAN_FRONTEND=noninteractive |
| 4 | echo "exit 101" > /usr/sbin/policy-rc.d |
| 5 | chmod +x /usr/sbin/policy-rc.d |
| 6 | |
| 7 | echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt |
| 8 | |
| 9 | # Overwrite default mirrors |
| 10 | echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted multiverse universe" > /etc/apt/sources.list |
| 11 | echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list |
| 12 | echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted multiverse universe" >> /etc/apt/sources.list |
| 13 | echo "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted multiverse universe" >> /etc/apt/sources.list |
| 14 | |
| 15 | apt-get clean |
| 16 | apt-get update |
| 17 | |
| 18 | # Useful tools |
| 19 | apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget |
| 20 | # Install common prerequisites |
| 21 | apt-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 |
| 24 | apt-get purge -y linux-image-* linux-headers-* |
| 25 | if [ ! -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 |
| 35 | fi |
| 36 | |
| 37 | apt-get -y upgrade |
| 38 | apt-get -y dist-upgrade |
| 39 | |
| 40 | apt-get autoremove --purge |
| 41 | |
| 42 | # Tmux fixes |
| 43 | cat << 'EOF' >> /etc/tmux.conf |
| 44 | set -g default-terminal "screen-256color" |
| 45 | set -g set-titles on |
| 46 | set -g xterm-keys on |
| 47 | EOF |
| 48 | |
| 49 | # Setup cloud-init |
| 50 | apt-get -y install cloud-init |
| 51 | |
| 52 | # Disable apt-daily |
| 53 | systemctl disable apt-daily.timer |
| 54 | |
| 55 | # Motd |
| 56 | apt-get -y install update-motd |
| 57 | rm -vf /etc/update-motd.d/* |
| 58 | echo "BUILD_TIMESTAMP=$(date '+%Y-%m-%d-%H-%M-%S' -u)" > /etc/image_version |
| 59 | echo "BUILD_TIMESTAMP_RFC=\"$(date -u -R)\"" >> /etc/image_version |
| 60 | cat << '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 |
| 66 | echo "Ubuntu 16.04 \"Xenial\" Mirantis cloud image" |
| 67 | echo "Build date: ${BUILD_TIMESTAMP_RFC}" |
| 68 | EOF |
| 69 | chmod +x /etc/update-motd.d/00-header-mirantis |
| 70 | |