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