diff --git a/autoconf/configure.in b/autoconf/configure.in index ba66299779f..0c198f7ae8e 100644 --- a/autoconf/configure.in +++ b/autoconf/configure.in @@ -3757,6 +3757,7 @@ debian/bareos-director.preinst \ debian/bareos-storage.preinst \ scripts/bareos-config \ scripts/bareos-config-lib.sh \ +scripts/bareos-explorer \ scripts/btraceback \ scripts/bconsole \ scripts/bareos \ diff --git a/debian/bareos-common.install b/debian/bareos-common.install index db521caffda..7d5851a49c1 100644 --- a/debian/bareos-common.install +++ b/debian/bareos-common.install @@ -1,5 +1,6 @@ /usr/lib/bareos/scripts/bareos-config /usr/lib/bareos/scripts/bareos-config-lib.sh +/usr/lib/bareos/scripts/bareos-explorer /usr/lib/bareos/scripts/btraceback.gdb /usr/lib/libbareos.so /usr/lib/libbareos-*.so diff --git a/platforms/packaging/bareos.spec b/platforms/packaging/bareos.spec index df5cebbf3bc..84e3a1391c0 100644 --- a/platforms/packaging/bareos.spec +++ b/platforms/packaging/bareos.spec @@ -742,6 +742,7 @@ echo "This is a meta package to install a full bareos system" > %{buildroot}%{_d %dir %{script_dir} %{script_dir}/bareos-config %{script_dir}/bareos-config-lib.sh +%{script_dir}/bareos-explorer %{script_dir}/btraceback.gdb %if "%{_libdir}/bareos/" != "/usr/lib/bareos/" %dir %{_libdir}/bareos/ diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 5abbaab1022..0e5db4fb9c8 100755 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -63,6 +63,7 @@ install: installdirs #$(INSTALL_SCRIPT) -m 700 bareos-password-setup.sh ${DESTDIR}${scriptdir}/bareos-password-setup.sh $(INSTALL_SCRIPT) bareos-config ${DESTDIR}${scriptdir}/bareos-config $(INSTALL_SCRIPT) bareos-config-lib.sh ${DESTDIR}${scriptdir}/bareos-config-lib.sh + $(INSTALL_SCRIPT) bareos-explorer ${DESTDIR}${scriptdir}/bareos-explorer $(INSTALL_SCRIPT) btraceback $(DESTDIR)$(sbindir)/btraceback #$(INSTALL_SCRIPT) logrotate $(DESTDIR)/etc/logrotate.d/bareos-dir diff --git a/scripts/bareos-explorer.in b/scripts/bareos-explorer.in new file mode 100755 index 00000000000..aadb5712b49 --- /dev/null +++ b/scripts/bareos-explorer.in @@ -0,0 +1,267 @@ +#!/bin/sh +# +# BAREOSĀ® - Backup Archiving REcovery Open Sourced +# +# Copyright (C) 2014-2014 Bareos GmbH & Co. KG +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of version three of the GNU Affero General Public +# License as published by the Free Software Foundation and included +# in the file LICENSE. +# +# 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 +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero 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. +# +# This script will collect all info of a bareos install like: +# - logfiles +# - bactraces +# - tracebacks +# - core files +# +set -a + +# +# Source the Bareos config functions. +# +. @scriptdir@/bareos-config-lib.sh + +working_dir=`get_working_dir` + +get_compression_method() +{ + # + # See what compression is available on the platform + # + bzip2=`which bzip2 2> /dev/null` + gzip=`which gzip 2> /dev/null` + + if [ ! -z "${bzip2}" ]; then + compressor="${bzip2} -z -c" + comp_suffix=".bz2" + else + if [ ! -z "${gzip}" ]; then + compressor="${gzip} -c" + comp_suffix=".gz" + else + compressor="cat" + comp_suffix="" + fi + fi +} + +collect_debug_info() +{ + # + # If there is a logfile capture it and compress them when possible. + # + if [ -f log ]; then + ${compressor} log > collect.$$/log${comp_suffix} + fi + + # + # Capture all core files and compress them when possible. + # + for file in *.core.* + do + ${compressor} ${file} > collect.$$/${file}${comp_suffix} + if [ ${REMOVE:-NO} = YES ]; then + rm -f ${file} + fi + done + + # + # Capture all bactrace files + # + for file in *.bactrace + do + cp -p ${file} collect.$$ + if [ ${REMOVE:-NO} = YES ]; then + rm -f ${file} + fi + done + + # + # Capture all traceback files + # + for file in *.traceback + do + cp -p ${file} collect.$$ + if [ ${REMOVE:-NO} = YES ]; then + rm -f ${file} + fi + done +} + +collect_pkg_info() +{ + case `uname -s` in + Linux) + LSB_DISTRIBUTOR=`lsb_release -i -s` + case ${LSB_DISTRIBUTOR} in + "SUSE LINUX") + PKG_TYPE="rpm" + if [ -f /etc/os-release ]; then + cat /etc/os-release + else + if [ -f /etc/SuSE-release ]; then + cat /etc/SuSE-release + fi + fi + ;; + "openSUSE project") + PKG_TYPE="rpm" + if [ -f /etc/os-release ]; then + cat /etc/os-release + else + if [ -f /etc/SuSE-release ]; then + cat /etc/SuSE-release + fi + fi + ;; + CentOS) + PKG_TYPE="rpm" + if [ -f /etc/redhat-release ]; then + cat /etc/redhat-release + fi + ;; + Fedora) + PKG_TYPE="rpm" + if [ -f /etc/fedora-release ]; then + cat /etc/fedora-release + fi + ;; + RedHatEnterprise*) + PKG_TYPE="rpm" + if [ -f /etc/redhat-release ]; then + cat /etc/redhat-release + fi + ;; + Oracle*) + PKG_TYPE="rpm" + ;; + MandrivaLinux) + PKG_TYPE="rpm" + ;; + Arch|archlinux) + ;; + LinuxMint) + ;; + Debian) + PKG_TYPE="deb" + if [ -f /etc/debian_version ]; then + cat /etc/debian_version + fi + ;; + Ubuntu) + PKG_TYPE="deb" + if [ -f /etc/debian_version ]; then + cat /etc/debian_version + fi + ;; + Univention) + PKG_TYPE="deb" + if [ -f /etc/debian_version ]; then + cat /etc/debian_version + fi + ;; + *) + ;; + esac + + case ${PKG_TYPE} in + deb) + dpkg-query -l '*bareos*' + ;; + rpm) + rpm -qa | grep bareos + ;; + *) + ;; + esac + ;; + SunOS) + for pkgname in `pkginfo | grep bareos | cut -d' ' -f2` + do + pkginfo -l ${pkgname} + done + ;; + *) + ;; + esac > collect.$$/pkginfo +} + +collect() +{ + output="bareos.capture.`date +%Y%m%d%H%M`.tar" + cd ${working_dir} || exit 1 + + # + # Create a collection dir + # + mkdir collect.$$ + + # + # See what compression we can use to make things somewhat smaller. + # + get_compression_method + + # + # Collect the debug information like postmortem core files, logs + # and bactrace and traceback files. + # + collect_debug_info + + # + # Collect the installed packages. + # + collect_pkg_info + + # + # tar up the whole capture folder + # + tar cf ${output} collect.$$ + rm -rf collect.$$ + + echo "Please upload the following file for support: ${workdir}/${output}" +} + +usage() +{ + echo "Usage: $0 [-hr]" +} + +main() +{ + # + # Parse options. + # + while getopts "hr" arg + do + case ${arg} in + r) + REMOVE="YES" + ;; + h|\?) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac + done + nr_shift=`expr $OPTIND - 1` + shift ${nr_shift} + + collect $* +} + +main $*