home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / root / sbin / save_y2logs < prev    next >
Text File  |  2006-11-29  |  1KB  |  66 lines

  1. #!/bin/bash
  2. #
  3. # save_y2logs - save YaST2 logs to a compressed tar file
  4. #        to attach it to a Bugzilla bug report
  5. #
  6. # Author: Stefan Hundhammer <sh@suse.de>
  7.  
  8. usage()
  9. {
  10.     echo "Usage: $0 <tgz-file-name>"
  11.     echo ""
  12.     echo "Copies the YaST2 logs to a compressed tar archive."
  13.     exit 1
  14. }
  15.  
  16. test -z "$1" && usage
  17.  
  18. case "$1" in
  19.     -*)
  20.     usage
  21.     ;;
  22.  
  23.     *.tgz|*.tar.gz)
  24.     TARGET="$1"
  25.     COMPRESSION=--gzip
  26.     ;;
  27.  
  28.     *.tar.bz2)
  29.     TARGET="$1"
  30.     COMPRESSION=--bzip2
  31.  
  32.     if [ ! -x /usr/bin/bzip2 ]; then
  33.         echo "FATAL: /usr/bin/bzip2 not available" >&2
  34.         # This might easily happen in the inst-sys
  35.             exit 3
  36.     fi
  37.     ;;
  38.  
  39.     *)
  40.     echo "FATAL: Uncompressed archives not supported" >&2
  41.     echo "Use one of: .tgz .tar.gz .tar.bz2"          >&2
  42.     exit 4
  43. esac
  44.  
  45.  
  46. LIST=YaST2
  47.  
  48. if [ -f /var/log/evms-engine.log ]; then
  49.     LIST="$LIST $( cd /var/log/; ls evms-engine.*)"
  50. fi
  51.  
  52. RPM_LIST="rpm-qa"
  53. rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE}\t\t\t(%{VENDOR})\t%{DISTRIBUTION}\n' | sort >/var/log/$RPM_LIST
  54.  
  55. if [ -f /var/log/$RPM_LIST ]; then
  56.     LIST="$LIST $RPM_LIST"
  57. fi
  58.  
  59. echo "Saving y2logs to $TARGET"
  60.  
  61. tar cf "$TARGET" $COMPRESSION --directory=/var/log $LIST && exit 0
  62.  
  63. echo "FATAL: Error creating archive $TARGET" >&2
  64. exit 2
  65.  
  66.