Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 1 | #!/bin/bash -xe |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 2 | |
| 3 | UBUNTU_BASEURL="${UBUNTU_BASEURL:-"mirror://mirrors.ubuntu.com/mirrors.txt"}" |
| 4 | |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 5 | ## Base packages and setup |
| 6 | export DEBIAN_FRONTEND=noninteractive |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame^] | 7 | echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 8 | chmod +x /usr/sbin/policy-rc.d |
| 9 | |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame^] | 10 | # Configure apt. Please refer to |
| 11 | # https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/single/debian.yml |
| 12 | # and keep those structures with same naming convention - to prevent |
| 13 | # misconfiguration between base system and salt state. |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 14 | echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 15 | echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 16 | echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt |
| 17 | echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt |
| 18 | echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt |
| 19 | echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt |
| 20 | echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt |
| 21 | echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt |
| 22 | echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 23 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 24 | sysctl -w fs.file-max=100000 |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 25 | # Overwrite default mirrors |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 26 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted multiverse universe" > /etc/apt/sources.list |
| 27 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted multiverse universe" >> /etc/apt/sources.list |
| 28 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted multiverse universe" >> /etc/apt/sources.list |
| 29 | #echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-backports main restricted multiverse universe" >> /etc/apt/sources.list |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 30 | |
| 31 | apt-get clean |
| 32 | apt-get update |
| 33 | |
| 34 | # Useful tools |
| 35 | apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget |
| 36 | # Install common prerequisites |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame^] | 37 | apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 38 | |
| 39 | # Cleanup old kernels, ensure latest is installed via virtual package |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 40 | if [ ! -f /tmp/no_install_kernel ]; then |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 41 | apt-get purge -y linux-image-* linux-headers-* |
| 42 | apt-get install -y linux-image-virtual-lts-xenial linux-image-extra-virtual-lts-xenial |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 43 | |
| 44 | # Update grub cmdline |
| 45 | sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 46 | sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 47 | update-grub |
| 48 | fi |
| 49 | |
| 50 | apt-get -y upgrade |
| 51 | apt-get -y dist-upgrade |
| 52 | |
| 53 | apt-get autoremove --purge |
| 54 | |
| 55 | # Tmux fixes |
| 56 | cat << 'EOF' >> /etc/tmux.conf |
| 57 | set -g default-terminal "screen-256color" |
| 58 | set -g set-titles on |
| 59 | set -g xterm-keys on |
| 60 | EOF |
| 61 | |
| 62 | # Setup cloud-init |
| 63 | apt-get -y install cloud-init |
| 64 | |
| 65 | # Disable apt-daily |
| 66 | systemctl disable apt-daily.timer |