blob: b0654556f42e9c9276f3050e561d3afccfda1471 [file] [log] [blame]
azvyagintseve1b236a2018-07-13 16:59:49 +03001#!/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
azvyagintsevc975d9e2018-07-17 20:27:39 +03008
9function prod_21514_wa() {
10 echo 'Apply WA for https://mirantis.jira.com/browse/PROD-20751'
11 echo 'Installing isc-dhcp from xenial'
12 echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted universe" > /etc/apt/sources.list.d/xenial.list
13 echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted universe" >> /etc/apt/sources.list.d/xenial.list
14 echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted universe" >> /etc/apt/sources.list.d/xenial.list
15 apt-get update
16 apt-get install -y isc-dhcp-client isc-dhcp-common
17 rm -v /etc/apt/sources.list.d/xenial.list || true
18}
19
20### Body
azvyagintseve1b236a2018-07-13 16:59:49 +030021UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}"
22## Base packages and setup
23export DEBIAN_FRONTEND=noninteractive
24echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
25chmod +x /usr/sbin/policy-rc.d
26
27# Configure apt. Please refer to
28# https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/single/debian.yml
29# and keep those structures with same naming convention - to prevent
30# misconfiguration between base system and salt state.
31echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt
32echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false
33echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt
34echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt
35echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt
36echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt
37echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt
38echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt
39echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt
40
41sysctl -w fs.file-max=100000
42# Overwrite default mirrors
43echo "deb [arch=amd64] ${UBUNTU_BASEURL} trusty main restricted universe" > /etc/apt/sources.list
44echo "deb [arch=amd64] ${UBUNTU_BASEURL} trusty-updates main restricted universe" >> /etc/apt/sources.list
45echo "deb [arch=amd64] ${UBUNTU_BASEURL} trusty-security main restricted universe" >> /etc/apt/sources.list
azvyagintsevc975d9e2018-07-17 20:27:39 +030046prod_21514_wa
azvyagintseve1b236a2018-07-13 16:59:49 +030047apt-get clean
48apt-get update
49
50# Useful tools
51EXTRA_PKGS="byobu curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables"
52# Pretty tools
53EXTRA_PKGS="${EXTRA_PKGS} byobu htop tmux tree vim-nox mc"
54# Common prerequisites
55EXTRA_PKGS="${EXTRA_PKGS} apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid"
azvyagintseve1b236a2018-07-13 16:59:49 +030056
57# Cleanup old kernels, ensure latest is installed via virtual package
58if [ ! -f /tmp/no_install_kernel ]; then
59 modprobe cpuid
60 apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed'
61 apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial
62
63 # Update grub cmdline
64 sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
65 sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub
66 update-grub
67fi
azvyagintseve1b236a2018-07-13 16:59:49 +030068apt-get -y upgrade
69apt-get -y dist-upgrade
70
azvyagintseve1b236a2018-07-13 16:59:49 +030071# Tmux fixes
72cat << 'EOF' >> /etc/tmux.conf
73set -g default-terminal "screen-256color"
74set -g set-titles on
75set -g xterm-keys on
76EOF
77
78# Setup cloud-init
79apt-get -y install cloud-init
80
81touch /done_ubuntu_base