azvyagintsev | 9a1737f | 2019-03-11 15:44:54 +0200 | [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 |
| 8 | # |
| 9 | UBUNTU_BASEURL="${UBUNTU_BASEURL:-mirror://mirrors.ubuntu.com/mirrors.txt}" |
| 10 | ## Base packages and setup |
| 11 | export DEBIAN_FRONTEND=noninteractive |
| 12 | echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d |
| 13 | chmod +x /usr/sbin/policy-rc.d |
| 14 | # 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. |
| 18 | echo "Acquire::CompressionTypes::Order gz;" >/etc/apt/apt.conf.d/99compression-workaround-salt |
| 19 | echo "Acquire::EnableSrvRecords false;" >/etc/apt/apt.conf.d/99enablesrvrecords-false |
| 20 | echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99aws-s3-mirrors-workaround-salt |
| 21 | echo "APT::Install-Recommends false;" > /etc/apt/apt.conf.d/99dont_install_recommends-salt |
| 22 | echo "APT::Install-Suggests false;" > /etc/apt/apt.conf.d/99dont_install_suggests-salt |
| 23 | echo "Acquire::Languages none;" > /etc/apt/apt.conf.d/99dont_acquire_all_languages-salt |
| 24 | echo "APT::Periodic::Update-Package-Lists 0;" > /etc/apt/apt.conf.d/99dont_update_package_list-salt |
| 25 | echo "APT::Periodic::Download-Upgradeable-Packages 0;" > /etc/apt/apt.conf.d/99dont_update_download_upg_packages-salt |
| 26 | echo "APT::Periodic::Unattended-Upgrade 0;" > /etc/apt/apt.conf.d/99disable_unattended_upgrade-salt |
| 27 | |
| 28 | sysctl -w fs.file-max=100000 |
| 29 | # Overwrite default mirrors |
| 30 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic main restricted universe" > /etc/apt/sources.list |
| 31 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic-updates main restricted universe" >> /etc/apt/sources.list |
| 32 | echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic-security main restricted universe" >> /etc/apt/sources.list |
| 33 | #echo "deb [arch=amd64] ${UBUNTU_BASEURL} bionic-backports main restricted universe" >> /etc/apt/sources.list |
| 34 | |
| 35 | apt-get clean |
| 36 | apt-get update |
| 37 | |
| 38 | # Useful tools |
| 39 | EXTRA_PKGS="byobu curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables" |
| 40 | # Pretty tools |
| 41 | EXTRA_PKGS="${EXTRA_PKGS} byobu htop tmux tree vim-nox mc eatmydata" |
| 42 | # Common prerequisites |
| 43 | # growlvm.py dependencies |
| 44 | GROWLVM_PKGS="python3-jsonschema python3-yaml" |
| 45 | EXTRA_PKGS="$EXTRA_PKGS $GROWLVM_PKGS gnupg2 apt-transport-https libmnl0 python3-apt python3-psutil acpid virt-what dbus bridge-utils vlan ifenslave" |
| 46 | apt-get -y install ${EXTRA_PKGS} |
| 47 | |
| 48 | # Cleanup old kernels, ensure latest is installed via metapackage package |
| 49 | if [ ! -f /tmp/no_install_kernel ]; then |
| 50 | apt-get purge -y linux-image-* linux-headers-* | grep -v 'is not installed, so not removed' |
| 51 | #apt-get install -y linux-image-virtual-hwe-18.04 linux-image-extra-virtual-hwe-18.04 linux-headers-generic-hwe-18.04 |
| 52 | apt-get install -y linux-image-virtual linux-image-extra-virtual linux-headers-generic |
| 53 | # Update grub cmdline |
| 54 | sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 55 | sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"|g' /etc/default/grub |
| 56 | update-grub |
| 57 | fi |
| 58 | |
| 59 | apt-get -y upgrade |
| 60 | apt-get -y dist-upgrade |
| 61 | |
| 62 | # Setup cloud-init |
| 63 | apt-get -y install cloud-init |
| 64 | |
| 65 | # FIXME: move to cluster model |
| 66 | # Disable services |
| 67 | disable_services="apt-daily.timer apt-daily-upgrade.timer lxc.service snapd.service snapd.socket open-iscsi.service tgt.service iscsid.service" |
| 68 | for s in ${disable_services}; do |
| 69 | systemctl disable ${s} || true |
| 70 | systemctl stop ${s} || true |
| 71 | done |
| 72 | |
| 73 | touch /done_ubuntu_base |