blob: 675bcfd687fbfbb66092b35bf9ae19f582a66410 [file] [log] [blame]
Jiri Broulik4ea221c2018-04-10 13:48:06 +02001#!/bin/bash -xe
2
3UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}"
4
5## Base packages and setup
6export DEBIAN_FRONTEND=noninteractive
7echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
8chmod +x /usr/sbin/policy-rc.d
9
10# 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.
14echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
15echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
16echo "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
23
24sysctl -w fs.file-max=100000
25# Overwrite default mirrors
26echo "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
30echo '127.0.0.1 localhost' >> /etc/hosts
31echo '127.0.0.1 cfg01 cfg' >> /etc/hosts
32
33apt-get clean
34apt-get update
35
36# Useful tools
37apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget
38# Install common prerequisites
39apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid
40
41# Cleanup old kernels, ensure latest is installed via virtual package
42if [ ! -f /tmp/no_install_kernel ]; then
43 apt-get purge -y linux-image-* linux-headers-*
44 apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial
45
46 # Update grub cmdline
47 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
48 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
49 update-grub
50fi
51
52apt-get -y upgrade
53apt-get -y dist-upgrade
54
55apt-get autoremove --purge
56
57# Tmux fixes
58cat << 'EOF' >> /etc/tmux.conf
59set -g default-terminal "screen-256color"
60set -g set-titles on
61set -g xterm-keys on
62EOF
63
64# Setup cloud-init
65apt-get -y install cloud-init
66
67# Disable apt-daily
68systemctl disable apt-daily.timer