From owner-svn-soc-all@FreeBSD.ORG Tue May 29 02:35:16 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id A6B471065670 for ; Tue, 29 May 2012 02:35:14 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 29 May 2012 02:35:14 +0000 Date: Tue, 29 May 2012 02:35:14 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120529023514.A6B471065670@hub.freebsd.org> Cc: Subject: socsvn commit: r236633 - soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2012 02:35:16 -0000 Author: tzabal Date: Tue May 29 02:35:14 2012 New Revision: 236633 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236633 Log: Updated version of /usr/sbin/crashreport. Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh ============================================================================== --- soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Tue May 29 02:35:13 2012 (r236632) +++ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Tue May 29 02:35:14 2012 (r236633) @@ -2,16 +2,16 @@ . /etc/rc.conf + print_usage() { echo "usage: $(basename $0) [-d dumpdir] [-f file] [-e email]" } -# Constants +# Default dump directory DUMPDIR='/var/crash' -# Script variables _dumpdir="" _file="" _email="" @@ -35,19 +35,11 @@ esac done -echo 'We start with:' -echo "_dumpdir = ${_dumpdir}" -echo "_file = ${_file}" -echo "_email = ${_email}" -echo '---------------' -echo 'We end up with:' ## Find the dump directory -# Check the parameter if [ -z "${_dumpdir}" ]; then - # Check the dumpdir of /etc/rc.conf + # dumpdir of /etc/rc.conf if [ -z "${dumpdir}" ]; then - # Use the default dumpdir _dumpdir=${DUMPDIR} else _dumpdir=${dumpdir} @@ -64,16 +56,14 @@ exit 2 fi -echo "_dumpdir = ${_dumpdir}" ## Find the file that contains the debugging information ## It is either a core.txt.X or a textdump.tar.X +X="" BOUNDS="${_dumpdir}/bounds" CORE="${_dumpdir}/core.txt" TEXTDUMP="${_dumpdir}/textdump.tar" -X="" -# Check the parameter if [ -z "${_file}" ]; then # Find it using the file bounds if [ -r "${BOUNDS}" ]; then @@ -86,7 +76,7 @@ fi # Otherwise, use this (heavier) way else - _file=`ls ${_dumpdir} | grep '[a-z]*\.[a-z]*\.\w*' | \ + _file=`ls ${_dumpdir} | egrep '[a-z]+\.[a-z]+\.[0-9]+' | \ sort -n -t . -k 3 | tail -1` fi fi @@ -96,12 +86,10 @@ exit 3 fi -echo "_file = ${_file}" ## Find the email that will be used for contact -# Check the parameter if [ -z "${_email}" ]; then - # The email of /etc/rc.conf + # email of /etc/rc.conf _email="${email}" fi @@ -115,14 +103,24 @@ > /dev/null if [ "$?" -ne "0" ]; then - echo "Email address ${_email} is invalid." + echo "crashreport: Email address ${_email} is invalid." exit 5 fi -echo "_email = ${_email}" -## Send the report -echo 'Sending the report...' +## Bundle the report +report="report.tar" +email_file=`mktemp /tmp/crashreport.XXXXXX` + +echo "${_email}" > ${email_file} +tar -c -f ${report} ${_dumpdir}/${_file} ${email_file} + + +## Send the report to the Central Collector machine +user="reporter" +hostname="akcrs.dyndns.org" +scp -q ${report} ${user}@${hostname}: + -# Everything went smooth +# Everything went smoothly exit 0 \ No newline at end of file