azvyagintsev | e1b236a | 2018-07-13 16:59:49 +0300 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | |
| 3 | # Don't use /tmp/ - some templates do node reboot |
| 4 | if [ -f /done_ubuntu_base ] ; then |
| 5 | echo "INFO: ubuntu_base already finished.Skipping.." |
| 6 | exit 0 |
| 7 | fi |
azvyagintsev | c975d9e | 2018-07-17 20:27:39 +0300 | [diff] [blame] | 8 | |
| 9 | function 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 |
azvyagintsev | e1b236a | 2018-07-13 16:59:49 +0300 | [diff] [blame] | 21 | UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}" |
| 22 | ## Base packages and setup |
| 23 | export DEBIAN_FRONTEND=noninteractive |
| 24 | echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d |
| 25 | chmod +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. |
| 31 | echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt |
| 32 | echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false |
| 33 | echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt |
| 34 | echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt |
| 35 | echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt |
| 36 | echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt |
| 37 | echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt |
| 38 | echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt |
| 39 | echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt |
| 40 | |
| 41 | sysctl -w fs.file-max=100000 |
| 42 | # Overwrite default mirrors |
| 43 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} trusty main restricted universe" > /etc/apt/sources.list |
| 44 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} trusty-updates main restricted universe" >> /etc/apt/sources.list |
| 45 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} trusty-security main restricted universe" >> /etc/apt/sources.list |
azvyagintsev | c975d9e | 2018-07-17 20:27:39 +0300 | [diff] [blame] | 46 | prod_21514_wa |
azvyagintsev | e1b236a | 2018-07-13 16:59:49 +0300 | [diff] [blame] | 47 | apt-get clean |
| 48 | apt-get update |
| 49 | |
| 50 | # Useful tools |
| 51 | EXTRA_PKGS="byobu curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables" |
| 52 | # Pretty tools |
| 53 | EXTRA_PKGS="${EXTRA_PKGS} byobu htop tmux tree vim-nox mc" |
| 54 | # Common prerequisites |
| 55 | EXTRA_PKGS="${EXTRA_PKGS} apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid" |
azvyagintsev | cb64acf | 2018-07-18 18:36:54 +0300 | [diff] [blame] | 56 | apt-get -y install ${EXTRA_PKGS} |
azvyagintsev | e1b236a | 2018-07-13 16:59:49 +0300 | [diff] [blame] | 57 | |
| 58 | # Cleanup old kernels, ensure latest is installed via virtual package |
| 59 | if [ ! -f /tmp/no_install_kernel ]; then |
| 60 | modprobe cpuid |
| 61 | apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed' |
| 62 | apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial |
| 63 | |
| 64 | # Update grub cmdline |
| 65 | sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 66 | sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 67 | update-grub |
| 68 | fi |
azvyagintsev | e1b236a | 2018-07-13 16:59:49 +0300 | [diff] [blame] | 69 | apt-get -y upgrade |
| 70 | apt-get -y dist-upgrade |
| 71 | |
azvyagintsev | e1b236a | 2018-07-13 16:59:49 +0300 | [diff] [blame] | 72 | # Tmux fixes |
| 73 | cat << 'EOF' >> /etc/tmux.conf |
| 74 | set -g default-terminal "screen-256color" |
| 75 | set -g set-titles on |
| 76 | set -g xterm-keys on |
| 77 | EOF |
| 78 | |
| 79 | # Setup cloud-init |
| 80 | apt-get -y install cloud-init |
| 81 | |
| 82 | touch /done_ubuntu_base |