blob: bae5120f7362bbdec287ae829b6f88d840e19a8c [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
azvyagintsevc86fbaf2018-03-02 18:57:03 +020012echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt
13echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt
14echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt
15echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt
16echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt
17echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt
18echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt
Richard Felkld59c5652018-02-08 13:14:05 +010019
azvyagintsev6d453852018-02-26 16:56:37 +020020sysctl -w fs.file-max=100000
Richard Felkld59c5652018-02-08 13:14:05 +010021# Overwrite default mirrors
azvyagintsev6d453852018-02-26 16:56:37 +020022echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted multiverse universe" > /etc/apt/sources.list
23echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list
24echo "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 Felkld59c5652018-02-08 13:14:05 +010026
27apt-get clean
28apt-get update
29
30# Useful tools
31apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget
32# Install common prerequisites
33apt-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 Felkld59c5652018-02-08 13:14:05 +010036if [ ! -f /tmp/no_install_kernel ]; then
azvyagintsev6d453852018-02-26 16:56:37 +020037 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 Felkld59c5652018-02-08 13:14:05 +010039
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
44fi
45
46apt-get -y upgrade
47apt-get -y dist-upgrade
48
49apt-get autoremove --purge
50
51# Tmux fixes
52cat << 'EOF' >> /etc/tmux.conf
53set -g default-terminal "screen-256color"
54set -g set-titles on
55set -g xterm-keys on
56EOF
57
58# Setup cloud-init
59apt-get -y install cloud-init
60
61# Disable apt-daily
62systemctl disable apt-daily.timer