Changeset 3800 in /cluster/svnroot


Ignore:
Timestamp:
Sep 8, 2012 3:09:07 PM (8 years ago)
Author:
skylar
Message:

support file working (#696)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/branches/skylar/bccd-3.1.1/trees/bin/bccd-report

    r3799 r3800  
    33# $Id$
    44
    5 set -eo pipefail
     5set -xeo pipefail
     6
     7function usage() {
     8        echo "$(basename -0) [ -n ]" >&2
     9        echo "Emails a troubleshooting file for BCCD developers." >&2
     10        echo "Run with -n to generate $HOME/bccd-report.tar.bz2 instead of email." >&2
     11}
     12
     13# Make TMPDIR global
     14declare TMPDIR
     15
     16# Cleanup temp directory if it exists
     17function cleanup() {
     18        if [ -d ${TMPDIR} ] && echo ${TMPDIR} | egrep -q '^/var/tmp'; then
     19                /bin/rm -fr ${TMPDIR}
     20        fi
     21}
     22
     23trap cleanup INT QUIT TERM EXIT ERR
    624
    725# This script gathers information from a BCCD system and emails it to the BCCD developers
     
    1129        echo "$(basename $0): Must be run as root!" >&2
    1230        exit 2
     31fi
     32
     33while getopts "nh" opt; do
     34        case $opt in
     35                n )
     36                        OUTFILE=~bccd/bccd-report.tar.bz2
     37                        ;;
     38                h )
     39                        HELP=1
     40                        ;;
     41                \?)
     42                        HELP=1
     43                        ;;
     44        esac
     45done
     46
     47if [[ ${HELP} -eq 1 ]]; then
     48        usage
     49        exit 1
    1350fi
    1451
     
    2865/bin/netstat -apn > $TMPDIR/netstat_apn.txt
    2966
    30 /bin/tar -C $TMPDIR -cvf - --exclude=bccd-report.tar.bz2 . |
    31         nice pbzip2 > $TMPDIR/bccd-report.tar.bz2
     67if [[ -n ${OUTFILE} ]]; then
     68        /bin/tar -C $TMPDIR -cf - .| \
     69                nice pbzip2 > ${OUTFILE}
     70        /bin/chown bccd:bccd ${OUTFILE}
     71else
     72        /bin/tar -C $TMPDIR -cf - .| \
     73                nice pbzip2 | \
     74                uuencode - | \
     75                mail -s "bccd-report for $(hostid)" bccd-developers@bccd.net
     76fi
Note: See TracChangeset for help on using the changeset viewer.