blob: fbb475e3149affaccb87d00e831b12111e9c3821 [file] [log] [blame]
Richard Felkld59c5652018-02-08 13:14:05 +01001#!/bin/bash -xe
azvyagintsev6d453852018-02-26 16:56:37 +02002
azvyagintsev29410ee2018-07-12 20:02:30 +03003# Don't use /tmp/ - some templates do node reboot
4if [ -f /done_ubuntu_base ] ; then
azvyagintsevb0daab12018-06-18 12:35:25 +03005 echo "INFO: ubuntu_base already finished.Skipping.."
6 exit 0
7fi
8#
azvyagintsev5a388552018-04-03 21:25:23 +03009UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}"
Richard Felkld59c5652018-02-08 13:14:05 +010010## Base packages and setup
11export DEBIAN_FRONTEND=noninteractive
azvyagintsev4053eb22018-03-29 16:21:51 +030012echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
Richard Felkld59c5652018-02-08 13:14:05 +010013chmod +x /usr/sbin/policy-rc.d
14
azvyagintsev4053eb22018-03-29 16:21:51 +030015# Configure apt. Please refer to
16# https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/single/debian.yml
17# and keep those structures with same naming convention - to prevent
18# misconfiguration between base system and salt state.
Richard Felkld59c5652018-02-08 13:14:05 +010019echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
azvyagintsev6d453852018-02-26 16:56:37 +020020echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
azvyagintsevc86fbaf2018-03-02 18:57:03 +020021echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt
22echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt
23echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt
24echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt
25echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt
26echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt
27echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt
Richard Felkld59c5652018-02-08 13:14:05 +010028
azvyagintsev6d453852018-02-26 16:56:37 +020029sysctl -w fs.file-max=100000
Richard Felkld59c5652018-02-08 13:14:05 +010030# Overwrite default mirrors
azvyagintsev29410ee2018-07-12 20:02:30 +030031echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted universe" > /etc/apt/sources.list
32echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted universe" >> /etc/apt/sources.list
33echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted universe" >> /etc/apt/sources.list
34#echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-backports main restricted universe" >> /etc/apt/sources.list
Richard Felkld59c5652018-02-08 13:14:05 +010035
36apt-get clean
37apt-get update
38
39# Useful tools
azvyagintsev0f697cf2018-06-22 11:44:13 +030040EXTRA_PKGS="byobu curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables"
41# Pretty tools
42EXTRA_PKGS="${EXTRA_PKGS} byobu htop tmux tree vim-nox mc"
43# Common prerequisites
azvyagintsev73fff7f2018-07-19 23:11:36 +030044EXTRA_PKGS="${EXTRA_PKGS} apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid virt-what"
azvyagintsev0f697cf2018-06-22 11:44:13 +030045apt-get -y install ${EXTRA_PKGS}
Richard Felkld59c5652018-02-08 13:14:05 +010046
azvyagintsev43971312018-05-31 18:08:30 +030047# Cleanup old kernels, ensure latest is installed via metapackage package
Richard Felkld59c5652018-02-08 13:14:05 +010048if [ ! -f /tmp/no_install_kernel ]; then
azvyagintsev0f697cf2018-06-22 11:44:13 +030049 apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed'
azvyagintsev2397e552018-10-04 11:25:18 +030050 apt-get install -y linux-image-virtual-hwe-16.04 linux-image-extra-virtual-hwe-16.04 linux-headers-generic-hwe-16.04
Richard Felkld59c5652018-02-08 13:14:05 +010051 # Update grub cmdline
52 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
53 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
54 update-grub
55fi
56
57apt-get -y upgrade
58apt-get -y dist-upgrade
59
Richard Felkld59c5652018-02-08 13:14:05 +010060# Setup cloud-init
61apt-get -y install cloud-init
62
azvyagintsev0adfe682018-06-13 16:29:40 +030063# FIXME: move to cluster model
64# Disable services
Ivan Berezovskiy9f5c7182018-09-06 13:36:25 +040065disable_services="apt-daily.timer apt-daily-upgrade.timer lxc.service snapd.service snapd.socket open-iscsi.service tgt.service iscsid.service"
azvyagintsev0adfe682018-06-13 16:29:40 +030066for s in ${disable_services}; do
67 systemctl disable ${s} || true
68 systemctl stop ${s} || true
69done
azvyagintsevb0daab12018-06-18 12:35:25 +030070
azvyagintsev29410ee2018-07-12 20:02:30 +030071touch /done_ubuntu_base