#!/bin/bash
# This file is part of Cockpit.
#
# Copyright (C) 2015 Red Hat, Inc.
#
# Cockpit is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Cockpit is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Cockpit; If not, see .
set -ex
# The docker pool should grow automatically as needed, but we grow it
# explicitly here anyway. This is hopefully more reliable.
# Newer Fedora versions configure docker to use the root LV
# HACK: docker falls over regularly, print its log if it does
systemctl start docker || journalctl -u docker
lvresize atomicos/root -l+60%FREE -r
if lvs atomicos/docker-pool 2>/dev/null; then
lvresize atomicos/docker-pool -l+100%FREE
elif lvs atomicos/docker-root-lv; then
lvresize atomicos/docker-root-lv -l+100%FREE
fi
# docker images that we need for integration testing
/var/lib/testvm/docker-images.setup
# Download the libssh RPM plus dependencies which we'll use for
# package overlay. The only way to do this is via a container
. /etc/os-release
REPO="updates"
if [ "$ID" = "rhel" ]; then
subscription-manager repos --enable rhel-7-server-extras-rpms
REPO="rhel-7-server-extras-rpms"
ID="rhel7"
fi
docker run --rm --volume=/etc/yum.repos.d:/etc/yum.repos.d:z --volume=/root/rpms:/tmp/rpms:rw,z "$ID:$VERSION_ID" /bin/sh -cex "yum install -y findutils createrepo yum-utils && (cd /tmp/; yumdownloader --enablerepo=$REPO libssh) && find /tmp -name '*.$(uname -m).*rpm' | while read rpm; do mv -v \$rpm /tmp/rpms; done; createrepo /tmp/rpms"
rm -f /etc/yum.repos.d/*
cat >/etc/yum.repos.d/deps.repo <> /etc/ssh/sshd_config
# Final tweaks
rm -rf /var/log/journal/*