#!/bin/bash
#
# Simple collector of common log files
#
# Copyright (c) 2020-2021 Virtuozzo International GmbH. All rights reserved.
#
# This file is part of vzreport. It's free software; you can redistribute
# it and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Our contact details: Virtuozzo International GmbH, Vordergasse 59, 8200
# Schaffhausen, Switzerland.
#

REPORT_DIR=$1
if [ -z "$REPORT_DIR" ]; then
    echo "Usage: $0 <REPORT_DIR>"
    exit 0
fi

VE0LOGFILES=`ls /var/log/{dmesg,boot.log,yum.log,libvirt.log,cpufeatures.log,vcmmd.log,prl*log*,ploop.log*,pcompact.log*,vzctl.log*,vztt.log*,messages*,kpatch.log*,anaconda/*.log,anaconda/syslog,phaul*.log,do-upgrade-vz7.log,sa/*} 2>/dev/null`

for i in $VE0LOGFILES; do
    if [ -f "$i" ]; then
        cp "$i" "$REPORT_DIR/"
    fi
done
