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 |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 12 | echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt |
| 13 | echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt |
| 14 | echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt |
| 15 | echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt |
| 16 | echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt |
| 17 | echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt |
| 18 | echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 19 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 20 | sysctl -w fs.file-max=100000 |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 21 | # Overwrite default mirrors |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 22 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted multiverse universe" > /etc/apt/sources.list |
| 23 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list |
| 24 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted multiverse universe" >> /etc/apt/sources.list |
| 25 | #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] | 26 | |
| 27 | apt-get clean |
| 28 | apt-get update |
| 29 | |
| 30 | # Useful tools |
| 31 | apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget |
| 32 | # Install common prerequisites |
| 33 | apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil |
| 34 | |
| 35 | # Cleanup old kernels, ensure latest is installed via virtual package |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 36 | if [ ! -f /tmp/no_install_kernel ]; then |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 37 | apt-get purge -y linux-image-* linux-headers-* |
| 38 | 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] | 39 | |
| 40 | # Update grub cmdline |
| 41 | sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 42 | sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 43 | update-grub |
| 44 | fi |
| 45 | |
| 46 | apt-get -y upgrade |
| 47 | apt-get -y dist-upgrade |
| 48 | |
| 49 | apt-get autoremove --purge |
| 50 | |
| 51 | # Tmux fixes |
| 52 | cat << 'EOF' >> /etc/tmux.conf |
| 53 | set -g default-terminal "screen-256color" |
| 54 | set -g set-titles on |
| 55 | set -g xterm-keys on |
| 56 | EOF |
| 57 | |
| 58 | # Setup cloud-init |
| 59 | apt-get -y install cloud-init |
| 60 | |
| 61 | # Disable apt-daily |
| 62 | systemctl disable apt-daily.timer |