blob: 4aa98c643e6b85f86b25582f504584e14d41bea0 [file] [log] [blame]
azvyagintsev9a1737f2019-03-11 15:44:54 +02001#!/bin/bash -xe
2
3# Don't use /tmp/ - some templates do node reboot
4if [ -f /done_ubuntu_base ] ; then
5 echo "INFO: ubuntu_base already finished.Skipping.."
6 exit 0
7fi
8#
9UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}"
10## Base packages and setup
11export DEBIAN_FRONTEND=noninteractive
12echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
13chmod +x /usr/sbin/policy-rc.d
14# 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.
18echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
19echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
20echo "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
27
28sysctl -w fs.file-max=100000
29# Overwrite default mirrors
30echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic main restricted universe" > /etc/apt/sources.list
31echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic-updates main restricted universe" >> /etc/apt/sources.list
32echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic-security main restricted universe" >> /etc/apt/sources.list
33#echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic-backports main restricted universe" >> /etc/apt/sources.list
34
35apt-get clean
36apt-get update
37
38# Useful tools
39EXTRA_PKGS="byobu curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables"
40# Pretty tools
41EXTRA_PKGS="${EXTRA_PKGS} byobu htop tmux tree vim-nox mc eatmydata"
42# Common prerequisites
43# growlvm.py dependencies
44GROWLVM_PKGS="python3-jsonschema python3-yaml"
45EXTRA_PKGS="$EXTRA_PKGS $GROWLVM_PKGS gnupg2 apt-transport-https libmnl0 python3-apt python3-psutil acpid virt-what dbus bridge-utils vlan ifenslave"
46apt-get -y install ${EXTRA_PKGS}
47
48# Cleanup old kernels, ensure latest is installed via metapackage package
49if [ ! -f /tmp/no_install_kernel ]; then
50 apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed'
51 #apt-get install -y linux-image-virtual-hwe-18.04 linux-image-extra-virtual-hwe-18.04 linux-headers-generic-hwe-18.04
52 apt-get install -y linux-image-virtual linux-image-extra-virtual linux-headers-generic
53 # Update grub cmdline
54 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
55 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
56 update-grub
57fi
58
59apt-get -y upgrade
60apt-get -y dist-upgrade
61
62# Setup cloud-init
63apt-get -y install cloud-init
64
65# FIXME: move to cluster model
66# Disable services
67disable_services="apt-daily.timer apt-daily-upgrade.timer lxc.service snapd.service snapd.socket open-iscsi.service tgt.service iscsid.service"
68for s in ${disable_services}; do
69 systemctl disable ${s} || true
70 systemctl stop ${s} || true
71done
72
73touch /done_ubuntu_base