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 | |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 3 | # Don't use /tmp/ - some templates do node reboot |
| 4 | if [ -f /done_ubuntu_base ] ; then |
azvyagintsev | b0daab1 | 2018-06-18 12:35:25 +0300 | [diff] [blame] | 5 | echo "INFO: ubuntu_base already finished.Skipping.." |
| 6 | exit 0 |
| 7 | fi |
| 8 | # |
azvyagintsev | 5a38855 | 2018-04-03 21:25:23 +0300 | [diff] [blame] | 9 | UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}" |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 10 | ## Base packages and setup |
| 11 | export DEBIAN_FRONTEND=noninteractive |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame] | 12 | echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 13 | chmod +x /usr/sbin/policy-rc.d |
| 14 | |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame] | 15 | # Configure apt. Please refer to |
| 16 | # https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/single/debian.yml |
| 17 | # and keep those structures with same naming convention - to prevent |
| 18 | # misconfiguration between base system and salt state. |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 19 | echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 20 | echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 21 | echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt |
| 22 | echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt |
| 23 | echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt |
| 24 | echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt |
| 25 | echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt |
| 26 | echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt |
| 27 | 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] | 28 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 29 | sysctl -w fs.file-max=100000 |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 30 | # Overwrite default mirrors |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 31 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial main restricted universe" > /etc/apt/sources.list |
| 32 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-updates main restricted universe" >> /etc/apt/sources.list |
| 33 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-security main restricted universe" >> /etc/apt/sources.list |
| 34 | #echo "deb [arch=amd64] ${UBUNTU_BASEURL} xenial-backports main restricted universe" >> /etc/apt/sources.list |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 35 | |
| 36 | apt-get clean |
| 37 | apt-get update |
| 38 | |
| 39 | # Useful tools |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 40 | EXTRA_PKGS="byobu curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables" |
| 41 | # Pretty tools |
| 42 | EXTRA_PKGS="${EXTRA_PKGS} byobu htop tmux tree vim-nox mc" |
| 43 | # Common prerequisites |
azvyagintsev | 73fff7f | 2018-07-19 23:11:36 +0300 | [diff] [blame] | 44 | EXTRA_PKGS="${EXTRA_PKGS} apt-transport-https libmnl0 python-apt python-m2crypto python-psutil acpid virt-what" |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 45 | apt-get -y install ${EXTRA_PKGS} |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 46 | |
azvyagintsev | 4397131 | 2018-05-31 18:08:30 +0300 | [diff] [blame^] | 47 | # Cleanup old kernels, ensure latest is installed via metapackage package |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 48 | if [ ! -f /tmp/no_install_kernel ]; then |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 49 | apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed' |
azvyagintsev | 4397131 | 2018-05-31 18:08:30 +0300 | [diff] [blame^] | 50 | apt-get install -y linux-image-virtual-hwe-16.04 linux-image-extra-virtual-hwe-16.04 |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 51 | |
| 52 | # Update grub cmdline |
| 53 | sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 54 | sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 55 | update-grub |
| 56 | fi |
| 57 | |
| 58 | apt-get -y upgrade |
| 59 | apt-get -y dist-upgrade |
| 60 | |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 61 | # Setup cloud-init |
| 62 | apt-get -y install cloud-init |
| 63 | |
azvyagintsev | 0adfe68 | 2018-06-13 16:29:40 +0300 | [diff] [blame] | 64 | # FIXME: move to cluster model |
| 65 | # Disable services |
| 66 | disable_services="apt-daily.timer apt-daily-upgrade.timer lxc.service snapd.service snapd.socket" |
| 67 | for s in ${disable_services}; do |
| 68 | systemctl disable ${s} || true |
| 69 | systemctl stop ${s} || true |
| 70 | done |
azvyagintsev | b0daab1 | 2018-06-18 12:35:25 +0300 | [diff] [blame] | 71 | |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 72 | touch /done_ubuntu_base |