blob: aafae3af236f4cd6257ce627d2d20b462de09d8f [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
azvyagintsev4053eb22018-03-29 16:21:51 +03007echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
Richard Felkld59c5652018-02-08 13:14:05 +01008chmod +x /usr/sbin/policy-rc.d
9
azvyagintsev4053eb22018-03-29 16:21:51 +030010# Configure apt. Please refer to
11# https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/single/debian.yml
12# and keep those structures with same naming convention - to prevent
13# misconfiguration between base system and salt state.
Richard Felkld59c5652018-02-08 13:14:05 +010014echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
azvyagintsev6d453852018-02-26 16:56:37 +020015echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
azvyagintsevc86fbaf2018-03-02 18:57:03 +020016echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt
17echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt
18echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt
19echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt
20echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt
21echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt
22echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt
Richard Felkld59c5652018-02-08 13:14:05 +010023
azvyagintsev6d453852018-02-26 16:56:37 +020024sysctl -w fs.file-max=100000
Richard Felkld59c5652018-02-08 13:14:05 +010025# Overwrite default mirrors
azvyagintsev6d453852018-02-26 16:56:37 +020026echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted multiverse universe" > /etc/apt/sources.list
27echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list
28echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted multiverse universe" >> /etc/apt/sources.list
29#echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-backports main restricted multiverse universe" >> /etc/apt/sources.list
Richard Felkld59c5652018-02-08 13:14:05 +010030
31apt-get clean
32apt-get update
33
34# Useful tools
35apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget
36# Install common prerequisites
azvyagintsev4053eb22018-03-29 16:21:51 +030037apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid
Richard Felkld59c5652018-02-08 13:14:05 +010038
39# Cleanup old kernels, ensure latest is installed via virtual package
Richard Felkld59c5652018-02-08 13:14:05 +010040if [ ! -f /tmp/no_install_kernel ]; then
azvyagintsev6d453852018-02-26 16:56:37 +020041 apt-get purge -y linux-image-* linux-headers-*
42 apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial
Richard Felkld59c5652018-02-08 13:14:05 +010043
44 # Update grub cmdline
45 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
46 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
47 update-grub
48fi
49
50apt-get -y upgrade
51apt-get -y dist-upgrade
52
53apt-get autoremove --purge
54
55# Tmux fixes
56cat << 'EOF' >> /etc/tmux.conf
57set -g default-terminal "screen-256color"
58set -g set-titles on
59set -g xterm-keys on
60EOF
61
62# Setup cloud-init
63apt-get -y install cloud-init
64
65# Disable apt-daily
66systemctl disable apt-daily.timer