blob: da6c81de430af5c5a4b2a73a124d2db6250247ac [file] [log] [blame]
Richard Felkld59c5652018-02-08 13:14:05 +01001#!/bin/bash -xe
azvyagintsev6d453852018-02-26 16:56:37 +02002
azvyagintsev5a388552018-04-03 21:25:23 +03003UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}"
azvyagintsev6d453852018-02-26 16:56:37 +02004
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
azvyagintsev0f697cf2018-06-22 11:44:13 +030035EXTRA_PKGS="byobu curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables"
36# Pretty tools
37EXTRA_PKGS="${EXTRA_PKGS} byobu htop tmux tree vim-nox mc"
38# Common prerequisites
39EXTRA_PKGS="${EXTRA_PKGS} apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid"
40apt-get -y install ${EXTRA_PKGS}
Richard Felkld59c5652018-02-08 13:14:05 +010041
42# Cleanup old kernels, ensure latest is installed via virtual package
Richard Felkld59c5652018-02-08 13:14:05 +010043if [ ! -f /tmp/no_install_kernel ]; then
azvyagintsev0f697cf2018-06-22 11:44:13 +030044 apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed'
azvyagintsev6d453852018-02-26 16:56:37 +020045 apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial
Richard Felkld59c5652018-02-08 13:14:05 +010046
47 # Update grub cmdline
48 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
49 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
50 update-grub
51fi
52
53apt-get -y upgrade
54apt-get -y dist-upgrade
55
56apt-get autoremove --purge
57
58# Tmux fixes
59cat << 'EOF' >> /etc/tmux.conf
60set -g default-terminal "screen-256color"
61set -g set-titles on
62set -g xterm-keys on
63EOF
64
65# Setup cloud-init
66apt-get -y install cloud-init
67
azvyagintsev0adfe682018-06-13 16:29:40 +030068# FIXME: move to cluster model
69# Disable services
70disable_services="apt-daily.timer apt-daily-upgrade.timer lxc.service snapd.service snapd.socket"
71for s in ${disable_services}; do
72 systemctl disable ${s} || true
73 systemctl stop ${s} || true
74done