blob: 10f1ee92733687da5dd5b891ab1640225f35f7d1 [file] [log] [blame]
Richard Felkld59c5652018-02-08 13:14:05 +01001#!/bin/bash -xe
azvyagintsev6d453852018-02-26 16:56:37 +02002
azvyagintsevb0daab12018-06-18 12:35:25 +03003if [ -f /tmp/done_ubuntu_base ] ; then
4 echo "INFO: ubuntu_base already finished.Skipping.."
5 exit 0
6fi
7#
azvyagintsev5a388552018-04-03 21:25:23 +03008UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}"
Richard Felkld59c5652018-02-08 13:14:05 +01009## Base packages and setup
10export DEBIAN_FRONTEND=noninteractive
azvyagintsev4053eb22018-03-29 16:21:51 +030011echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
Richard Felkld59c5652018-02-08 13:14:05 +010012chmod +x /usr/sbin/policy-rc.d
13
azvyagintsev4053eb22018-03-29 16:21:51 +030014# Configure apt. Please refer to
15# https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/single/debian.yml
16# and keep those structures with same naming convention - to prevent
17# misconfiguration between base system and salt state.
Richard Felkld59c5652018-02-08 13:14:05 +010018echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
azvyagintsev6d453852018-02-26 16:56:37 +020019echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
azvyagintsevc86fbaf2018-03-02 18:57:03 +020020echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt
21echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt
22echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt
23echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt
24echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt
25echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt
26echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt
Richard Felkld59c5652018-02-08 13:14:05 +010027
azvyagintsev6d453852018-02-26 16:56:37 +020028sysctl -w fs.file-max=100000
Richard Felkld59c5652018-02-08 13:14:05 +010029# Overwrite default mirrors
azvyagintsev6d453852018-02-26 16:56:37 +020030echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted multiverse universe" > /etc/apt/sources.list
31echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list
32echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted multiverse universe" >> /etc/apt/sources.list
33#echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-backports main restricted multiverse universe" >> /etc/apt/sources.list
Richard Felkld59c5652018-02-08 13:14:05 +010034
35apt-get clean
36apt-get update
37
38# Useful tools
39apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget
40# Install common prerequisites
azvyagintsev4053eb22018-03-29 16:21:51 +030041apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid
Richard Felkld59c5652018-02-08 13:14:05 +010042
43# Cleanup old kernels, ensure latest is installed via virtual package
Richard Felkld59c5652018-02-08 13:14:05 +010044if [ ! -f /tmp/no_install_kernel ]; then
azvyagintsev6d453852018-02-26 16:56:37 +020045 apt-get purge -y linux-image-* linux-headers-*
46 apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial
Richard Felkld59c5652018-02-08 13:14:05 +010047
48 # Update grub cmdline
49 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
50 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
51 update-grub
52fi
53
54apt-get -y upgrade
55apt-get -y dist-upgrade
56
57apt-get autoremove --purge
58
59# Tmux fixes
60cat << 'EOF' >> /etc/tmux.conf
61set -g default-terminal "screen-256color"
62set -g set-titles on
63set -g xterm-keys on
64EOF
65
66# Setup cloud-init
67apt-get -y install cloud-init
68
azvyagintsev0adfe682018-06-13 16:29:40 +030069# FIXME: move to cluster model
70# Disable services
71disable_services="apt-daily.timer apt-daily-upgrade.timer lxc.service snapd.service snapd.socket"
72for s in ${disable_services}; do
73 systemctl disable ${s} || true
74 systemctl stop ${s} || true
75done
azvyagintsevb0daab12018-06-18 12:35:25 +030076
77touch /tmp/done_ubuntu_base