#! /bin/bash # Shared .setup between all Debian/Ubuntu flavors set -ex # Enable a console on ttyS0 so that we can log-in via vm-run. # and make the boot up more verbose sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT/# GRUB_CMDLINE_LINUX_DEFAULT/' /etc/default/grub # We install all dependencies of the cockpit packages since we want # them to not spontaneously change from one test run to the next when # the distribution repository is updated. # COCKPIT_DEPS="\ cryptsetup \ docker.io \ libblockdev-mdraid2 \ libjson-glib-1.0-0 \ libpcp3 \ libpolkit-agent-1-0 \ libpolkit-gobject-1-0 \ libpwquality-tools \ libssh-4 \ libteam-utils \ libvirt-daemon-system \ libvirt-dbus \ libosinfo-bin \ network-manager \ pcp \ policykit-1 \ python3-dbus \ qemu-block-extra \ realmd \ selinux-basics \ thin-provisioning-tools \ unattended-upgrades \ tuned \ xdg-utils \ udisks2 \ udisks2-lvm2 \ " # We also install the packages necessary to join a FreeIPA domain so # that we don't have to go to the network during a test run. IPA_CLIENT_PACKAGES="\ freeipa-client \ sssd-tools \ sssd-dbus \ packagekit \ " TEST_PACKAGES="\ acl \ curl \ firewalld \ gdb \ iproute2 \ mdadm \ nfs-server \ qemu-kvm \ socat \ systemd-coredump \ virtinst \ xfsprogs \ sosreport \ " RELEASE=$(grep -m1 ^deb /etc/apt/sources.list | awk '{print $3}') case "$RELEASE" in bionic) # these packages are not in Ubuntu 18.04 COCKPIT_DEPS="${COCKPIT_DEPS/libvirt-dbus /}" ;; esac if grep -q 'ID=ubuntu' /etc/os-release; then PBUILDER_OPTS='COMPONENTS="main universe"' # We want to use/test NetworkManager instead of netplan/networkd for ethernets mkdir -p /etc/NetworkManager/conf.d touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf fi useradd -m -U -c Administrator -G sudo -s /bin/bash admin echo admin:foobar | chpasswd export DEBIAN_FRONTEND=noninteractive apt-get -y update DEBIAN_FRONTEND=noninteractive eatmydata apt-get -y dist-upgrade eatmydata apt-get -y install $TEST_PACKAGES $COCKPIT_DEPS $IPA_CLIENT_PACKAGES [ -z "$COCKPIT_DEPS_EXPERIMENTAL" ] || eatmydata apt-get -y install $COCKPIT_DEPS_EXPERIMENTAL # Prepare for building # # extract control files and adjust them for our release, so that we can parse the build deps mkdir -p /tmp/out curl -L https://github.com/cockpit-project/cockpit/archive/master.tar.gz | tar -C /tmp/out --strip-components=1 --wildcards -zxf - '*/debian/' /tmp/out/tools/debian/adjust-for-release $(lsb_release -sc) # Disable build-dep installation for the real builds cat > ~/.pbuilderrc <<- EOF DISTRIBUTION=$RELEASE PBUILDERSATISFYDEPENDSCMD=true $PBUILDER_OPTS EOF eatmydata apt-get -y install dpkg-dev pbuilder pbuilder --create --extrapackages "fakeroot $PBUILDER_EXTRA" /usr/lib/pbuilder/pbuilder-satisfydepends-classic --control /tmp/out/tools/debian/control --force-version --echo|grep apt-get | pbuilder --login --save-after-login rm -rf /tmp/out # Debian does not automatically start the default libvirt network virsh net-autostart default # Don't automatically update on boot or daily systemctl disable apt-daily.service apt-daily.timer || true # Enable coredumping via systemd echo "kernel.core_pattern=|/lib/systemd/systemd-coredump %P %u %g %s %t %c %e" > /etc/sysctl.d/50-coredump.conf printf 'DefaultLimitCORE=infinity\n' >> /etc/systemd/system.conf # HACK: we need to restart it in case aufs-dkms was installed after docker.io # and thus docker.io auto-switches its backend systemctl restart docker || journalctl -u docker I=$(docker info) if ! echo "$I" | grep -Eq 'Storage.*(aufs|overlay)'; then echo "ERROR! docker does not use aufs or overlayfs" exit 1 fi # docker images that we need for integration testing /var/lib/testvm/docker-images.setup rm -rf /var/lib/docker/devicemapper # in case there are unnecessary packages eatmydata apt-get -y autoremove || true # reduce image size apt-get clean pbuilder clean rm -f /var/cache/apt/*cache.bin /var/lib/testvm/zero-disk.setup # Final tweaks # Enable persistent journal mkdir -p /var/log/journal # Allow root login with password sed -i 's/^[# ]*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config # At least debian-9 virt-install image only has RSA key [ -e /etc/ssh/ssh_host_ed25519_key ] || ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t ed25519 [ -e /etc/ssh/ssh_host_ecdsa_key ] || ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa # Prevent SSH from hanging for a long time when no external network access echo 'UseDNS no' >> /etc/ssh/sshd_config # HACK: https://bugzilla.mindrot.org/show_bug.cgi?id=2512 # Disable the restarting of sshd when networking changes ln -snf /bin/true /etc/network/if-up.d/openssh-server # Stop showing 'To run a command as administrator (user "root"), use "sudo ". See "man # sudo_root" for details.` message in admins terminal. touch /home/admin/.sudo_as_admin_successful