blob: 336662b723b408d98be70cdf4b92d802269f9ff6 [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
azvyagintsev0f697cf2018-06-22 11:44:13 +030039EXTRA_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"
42# Common prerequisites
43EXTRA_PKGS="${EXTRA_PKGS} apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid"
44apt-get -y install ${EXTRA_PKGS}
Richard Felkld59c5652018-02-08 13:14:05 +010045
46# Cleanup old kernels, ensure latest is installed via virtual package
Richard Felkld59c5652018-02-08 13:14:05 +010047if [ ! -f /tmp/no_install_kernel ]; then
azvyagintsev0f697cf2018-06-22 11:44:13 +030048 apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed'
azvyagintsev6d453852018-02-26 16:56:37 +020049 apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial
Richard Felkld59c5652018-02-08 13:14:05 +010050
51 # 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
60apt-get autoremove --purge
61
62# Tmux fixes
63cat << 'EOF' >> /etc/tmux.conf
64set -g default-terminal "screen-256color"
65set -g set-titles on
66set -g xterm-keys on
67EOF
68
69# Setup cloud-init
70apt-get -y install cloud-init
71
azvyagintsev0adfe682018-06-13 16:29:40 +030072# FIXME: move to cluster model
73# Disable services
74disable_services="apt-daily.timer apt-daily-upgrade.timer lxc.service snapd.service snapd.socket"
75for s in ${disable_services}; do
76 systemctl disable ${s} || true
77 systemctl stop ${s} || true
78done
azvyagintsevb0daab12018-06-18 12:35:25 +030079
80touch /tmp/done_ubuntu_base