aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/README.rh-upload (renamed from src/README.rh-upload-core)2
-rwxr-xr-xsrc/extras/rh-upload283
-rwxr-xr-xsrc/extras/rh-upload-core323
-rw-r--r--src/setup.py2
-rw-r--r--src/sos.spec9
5 files changed, 291 insertions, 328 deletions
diff --git a/src/README.rh-upload-core b/src/README.rh-upload
index c03f5d56..6dd36aef 100644
--- a/src/README.rh-upload-core
+++ b/src/README.rh-upload
@@ -1,5 +1,5 @@
-rh-upload-core
+rh-upload
This is a script provided with the SOS RPM which provides some automation for RHEL kernel vmcore file
handling. The script is capable of compressing, encrypting, checksumming, splitting and uploading a
diff --git a/src/extras/rh-upload b/src/extras/rh-upload
new file mode 100755
index 00000000..5837b787
--- /dev/null
+++ b/src/extras/rh-upload
@@ -0,0 +1,283 @@
+#!/bin/bash
+
+#################################################################################
+# #
+# rh-upload #
+# Version - 0.3 #
+# Copyright (c) 2007 Red Hat, Inc. All rights reserved. #
+# #
+# #
+# Written by David Mair #
+# Cleanup and generalized for any kind of file by Olivier Arsac #
+# Idea stolen from Chris Snook :-) #
+# #
+# Purpose - To help in the automatic upload of files. #
+# Specifically, this script will compress, encrypt, md5sum, #
+# and upload the file automatically when invoked. #
+# Items are optional and specified by command line switch. #
+# ###############################################################################
+
+
+## Global directives
+umask 0077
+
+## Declare some variables
+Date=`/bin/date -u +%G%m%d%k%M%S | /usr/bin/tr -d ' '`
+Destination="dropbox.redhat.com"
+
+function usage {
+cat <<EOF
+rh-upload [-cehnNq] [-s size of hunks in MB] -f filename
+ rh-upload automates the upload of files to the Red Hat ftp.
+ The script helps the user to compress, checksum, encrypt and upload a file.
+ -c|--checksum : perform an md5 checksum on the file
+ -e|--encrypt : encrypt the file
+ -f|--file : file to act on (required)
+ -h|--help : show this usage help
+ -z|--compress : compress the file
+ -n|--noupload : Do NOT upload
+ -q|--quiet : Do everything I ask and do it quietly
+ -s|--split : split file into small hunks
+
+EOF
+}
+
+
+# echo to stderr
+function echoe(){
+ echo -e "$@" 1>&2
+}
+
+# echo unless in verbosity is too low
+function echov(){
+ local level="$1"
+ shift
+ if [[ $Verbose -ge "$level" ]]; then echo -e "$@"; fi
+}
+
+# Parse command line options (and perform some checks)
+function parse(){
+ if [ $# == 0 ]; then
+ usage
+ exit 0
+ fi
+
+ TEMP=`getopt -o heuczqs:f:n --long help,encrypt,quiet,noupload,checksum,compress,split:,file: -n 'rh-upload' -- "$@"`
+
+ if [ $? != 0 ]; then
+ echo "Options error -- Terminating..." >&2
+ usage
+ exit 1
+ fi
+
+ eval set -- "$TEMP"
+ Upload=1
+ Split=0
+ Verbose=1
+ Compress=0
+ Encrypt=0
+ Force=0
+ while true; do
+ case "$1" in
+ -h|--help) usage; exit 0;;
+ -e|--encrypt) Encrypt=1; shift;;
+ -N|--noupload) Upload=0; shift;;
+ -c|--checksum) Checksum=1; shift;;
+ -q|--quiet) Verbose=0; shift;;
+ -z|--compress) Compress=1; shift;;
+ -s|--split)
+ case $2 in
+ "") echoe "You must specify a hunk size."; exit 1 ;;
+ *) Split=$2; shift 2;;
+ esac ;;
+ -F|--force) Force=1; shift;;
+ -f|--file)
+ case "$2" in
+ "") echoe "You must specify a file name."; exit 1 ;;
+ *) File=$2; shift 2;;
+ esac ;;
+ --) shift; break ;;
+ *) echoe "Wrong options or flag specified"; usage; exit 1;;
+ esac
+ done
+
+ # Ensure the -f||--file flag was passed or die
+ if [ -z "$File" ]; then
+ echoe "The -f or --file flag is required! Terminating."
+ usage
+ exit 1
+ fi
+
+ # Validate the file exists or die
+ if [ ! -f "$File" ]; then
+ echoe "Invalid filename or file not found. Terminating."
+ exit 1
+ fi
+ File_dirname=${File%/*}
+ File_basename=${File##*/}
+ File_ext=${File_basename##*.}
+ Src_file="$File"
+ Dst_file="$File_basename"
+}
+
+function ticket(){
+ echov 1
+ echov 1 "We'll need to use your issue-tracker ticket number for a couple of things."
+ echo -n "Please enter ticket number: "
+ read Ticket_number
+ Dst_file="${Ticket_number}-${Date}-${File_basename}"
+}
+
+# Compress the file
+function compress(){
+ if [ "$Compress" != 0 ]; then
+ echov 1 "Starting file compression. This may take some time."
+ # Begin compression of file
+ if [ ! -x /usr/bin/gzip ]; then
+ echoe "Cannot find gzip in /usr/bin/. Terminating."
+ exit 1
+ else
+ /usr/bin/gzip --fast "$Src_file"
+ fi
+ Src_file="${Src_file}.gz"
+ Dst_file="${Dst_file}.gz"
+ fi
+}
+
+# Encrypt the file
+function encrypt(){
+ if [ "$Encrypt" != 0 ]; then
+ echov 1 "Encrypting file. This should only take a few minutes."
+ if [ ! -x /usr/bin/openssl ]; then
+ echoe "Cannot find openssl in /usr/bin. Terminating."
+ exit 1
+ fi
+ # Use the ticket number as the ssl keyfile name
+ Key_file="${Ticket_number}-${Date}.key"
+ /usr/bin/openssl rand -out "$Key_file" -base64 48
+ echov 1 "You have chosen to encrypt your file. Your passkey file is: $Key_file"
+ echov 1 "Please attach this key to your ticket."
+ /usr/bin/openssl aes-128-cbc -in $Src_file -out $Src_file.aes -pass file:"$Key_file"
+ Src_file="$Src_file.aes"
+ Dst_file="$Dst_file.aes"
+ fi
+}
+
+function checksum(){
+ if [ "$Checksum" != 0 ]; then
+ echov 1 "Cheksuming $Src_file... (This should only take a few minutes)"
+ if [ ! -x /usr/bin/md5sum ]; then
+ echoe "Cannot find md5sum in /usr/bin. Terminating."
+ exit 1
+ fi
+ MD5_file="${Ticket_number}-${Date}-checksum.out"
+ MD5_result=`/usr/bin/md5sum "$Src_file" | awk '{print $1}'`
+ echo "$MD5_result" > "$MD5_file"
+ echov 1 "The MD5 checksum is $MD5_result (in $MD5_file)."
+ fi
+}
+
+function split(){
+ if [ "$Split" -eq 0 ]; then
+ return
+ fi
+ local hunk_size="$Split"
+ if [[ "$hunk_size" -gt 0 ]] && [[ "$hunk_size" -lt 1001 ]]; then
+ if [ ! -x /usr/bin/split ]; then
+ echoe "Cannot find split in /usr/bin. Terminating."
+ exit 1
+ fi
+ Split_dir="${Ticket_number}-${Date}"
+ # We need to make a directory to keep things sane
+ echov 1 "Creating directory $Split_dir to house file hunks..."
+ /bin/mkdir "$Split_dir"
+ echov 1 "Splitting $Src_file..."
+ /usr/bin/split -b "$hunk_size"m -d "$Src_file" "${Split_dir}/${Dst_file}"
+ else
+ echoe "Invalid hunk size argument. Please enter a number greater than 0 and less than 1001. Terminating."
+ exit 1
+ fi
+}
+
+function upload(){
+ if [ "$Upload" -eq 0 ]; then
+ echov 1 "All file operations are complete. The file(s) is ready to upload at your convenience."
+ return
+ fi
+ echov 1 "The file(s) will now be uploaded."
+ echo -n "Please enter the destination host (default is $Destination): "
+ local destination_input
+ read destination_input
+ if [ "$destination_input" != "" ]; then
+ Destination=$destination_input
+ fi
+ echov 1
+ echov 1 "Uploading to $Destination... (This could take quite a while)."
+ if [ ! -x /usr/bin/lftp ]; then
+ # No lftp installed
+ echov 1 "lftp could not be found in /usr/bin. The file(s) will need to be uploaded manually."
+ Ftp_res=255
+ else
+ # Make the lftp script first
+ local script="/tmp/rh-upload-lftp.$$"
+ echo "lftp $Destination <<EOF" > $script
+ echo "cd incoming" >> $script
+ if [ "$Split" != 0 ]; then
+ echo "lcd $Split_dir" >> $script
+ echo "mirror -R" >> $script
+ else
+ echo "put $Src_file -o $Dst_file" >> $script
+ fi
+ echo "exit" >> $script
+ echo "EOF" >> $script
+ /usr/bin/lftp -f $script
+ Ftp_res=$?
+ fi
+}
+
+function closure(){
+ if [ "$Encrypt" != 0 ]; then
+ echov 1 "## File was encrypted with key $Key_file."
+ echov 1 "Please upload this key file to Issue Tracker or send it to your support representative for decryption after upload."
+ fi
+
+ if [ "$Checksum" != 0 ]; then
+ echov 1 "## A checksum was performed on your file."
+ echov 1 "The MD5 checksum is $MD5_result (in $MD5_file)."
+ echov 1 "Please include this when updating your ticket so your support representative can verify the copy uploaded."
+ fi
+
+ if [ "$Split" != 0 ]; then
+ echov 1 "## Your file was split and the hunks are in: $Split_dir/ "
+ fi
+
+ if [ "$Ftp_res" -eq 0 ]; then
+ echov 1 "This script has completed successfully the upload."
+ if [ "$Compress" != 0 ] || [ "$Split" != 0 ]; then
+ echov 1 "You performed file encryption and/or file splitting."
+ echov 1 "You may consider removing those temporary files."
+ fi
+ else
+ echoe "Sorry unable to upload the files to $Destination. You may want to retry or do it manually."
+ fi
+
+ if [ "$Compress" != 0 ]; then
+ echov 1 "It is NOT recommended to remove the gzipped copy of the file."
+ echov 1 "This is the only remaining copy of the file on your system."
+ echov 1 "It is recommended to retain the file until your support representative indicates that the problem has been identified and/or resolved."
+ fi
+}
+
+function main(){
+ # Run through the functions
+ parse $@
+ ticket
+ compress
+ encrypt
+ checksum
+ split
+ upload
+ closure
+}
+
+main $@
diff --git a/src/extras/rh-upload-core b/src/extras/rh-upload-core
deleted file mode 100755
index 4bea9478..00000000
--- a/src/extras/rh-upload-core
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/bin/bash
-
-#################################################################################
-# #
-# upload-core #
-# Version - 0.2 #
-# Copyright (c) 2007 Red Hat, Inc. All rights reserved. #
-# #
-# #
-# Written by David Mair #
-# Idea stolen from Chris Snook :-) #
-# #
-# Purpose - To help in the automation and encryption of kernel vmcore files. #
-# Specifically, this script will compress, encrypt, md5sum, #
-# and upload the core file automatically when invoked. #
-# Items are optional and specified by command line switch. #
-# ###############################################################################
-
-## Global directives
-umask 0077
-
-## Declare some variables
-date=`/bin/date -u +%G%m%d%k%M%S | /usr/bin/tr -d ' '`
-destination="dropbox.redhat.com/incoming"
-NOUPLOAD=NO
-SPLIT=0
-
-
-## Let's explain the usage
-
-function usage {
- echo
- echo
- echo "Upload-core is a shell script for automating the handling of kernel vmcore files"
- echo "for system administrators when working with support technicians."
- echo "The script allows echo the user to compress, checksum, encrypt and upload a core"
- echo "file with one command."
- echo
- echo "Usage: upload-core [-cehnNq] [-s size of hunks in MB] -f filename"
- echo
- echo "-c|--checksum : perform an md5 checksum on the file"
- echo "-e|--encrypt : encrypt the core file"
- echo "-f|--file : file to act on (required)"
- echo "-h|--help : show this usage help"
- echo "-n|--nocompress: do not compress the file (otherwise the file will be gzipped)"
- echo "-N|--noupload : Do NOT upload to an ftp drop box"
- echo "-q|--quiet : Do everything I ask and do it quietly"
- echo "-s|--split : split file into small hunks"
- echo
- echo
- exit 0
-}
-
-if [ $# == 0 ]; then usage
-fi
-
-TEMP=`getopt -o heucnqs:f:N --long help,encrypt,quiet,noupload,checksum,nocompress,split:,file: -n 'upload-core.sh' -- "$@"`
-
-if [ $? != 0 ]; then echo "Options error -- Terminating..." >&2; exit 1; fi
-
-eval set -- "$TEMP"
-
-while true ; do
- case "$1" in
- -h|--help) usage;;
- -e|--encrypt) ENCRYPT=yes; shift;;
- -N|--noupload) NOUPLOAD=yes; shift;;
- -c|--checksum) CHECKSUM=yes; shift;;
- -q|--quiet) QUIET=yes; shift;;
- -n|--nocompress) NOCOMPRESS=yes; shift;;
- -s|--split)
- case $2 in
- "") echo "You must specify a hunk size." >&2; exit 1 ;;
- *) SPLIT=$2; shift 2;;
- esac ;;
- -F|--force) FORCE=yes; shift;;
- -f|--file)
- case "$2" in
- "") echo "You must specify a file name." >&2; exit 1 ;;
- *) FILE=$2; shift 2;;
- esac ;;
- --) shift; break ;;
- *) echo "Wrong options or flag specified"; usage;;
- esac
-done
-
-
-# Okay, let's do some work!
-
-# Ensure the -f||--file flag was passed or die
-
-if test -z $FILE; then echo; echo "The -f or --file flag is required! Terminating."; echo; exit 1; fi
-
-# Validate the file exists or die
-
-if [ ! -f $FILE ]; then echo "Invalid filename or file not found. Terminating."; exit 1; fi
-
-function repeat {
-
-if [ "$QUIET" = "yes" ]; then return
-else
-
-# Let's repeat back to the user what we're doing and make sure this is what they really wanted.
-echo
-if [ "$ENCRYPT" = "yes" ] ; then echo " ## Will encrypt the file.";echo; fi
-
-if [ "$NOUPLOAD" = "yes" ] ; then echo " ## Will NOT upload the file.";echo; fi
-
-if [ "$CHECKSUM" = "yes" ] ; then echo " ## Will checksum the file.";echo; fi
-
-if [ "$SPLIT" != "FALSE" ] ; then echo " ## Will split the file.";echo; fi
-
-if [ "$NOCOMPRESS" = "yes" ] ; then echo -e " ## Will \E[41;30m\033[5mNOT\033[0m compress the file. Are you sure?";echo; else echo "Compressing $FILE"; echo; fi
-fi
-}
-
-
-function warn {
-
-if [ "$QUIET" = "yes" ]; then return
-else
-echo "Please note that depending upon the size of your vmcore file this could take"
-echo "quite some time to run. If the options listed above are correct please"
-echo "press enter. Otherwise press <ctrl>-<c> to exit the program and start again."
-echo
-read IGNORE
-echo
-fi
-}
-
-function ticket {
-echo
-echo "We'll need to use your trouble ticket number for a couple of things. Please"
-echo "enter your trouble ticket number:"
-read ticket_number
-echo
-return
-}
-
-function file_ops {
-# Need to rename the core file before we compress it
-if [ "$QUIET" != "yes" ]; then echo "Renaming core file $ticket_number-$date-vmcore"; fi
-
-new_file=$ticket_number-$date-vmcore
-
-/bin/mv $FILE $new_file
-}
-
-# Compress the file
-function compress {
-
-if [ "$NOCOMPRESS" = "yes" ]
- then
- if [ "$QUIET" != "yes"]; then echo "Skipping compression step.";echo; fi
-
- else
- if [ "$QUIET" != "yes" ]; then echo "Starting file compression. This will take some time.";echo; fi
- # Begin compression of file
- if [ ! /usr/bin/gzip ]; then
- echo "Cannot find gzip in /usr/bin/. Terminating."; exit 1
- else
- /usr/bin/gzip --fast $new_file
- fi
-
-fi
-
-new_file="$new_file.gz"
-
-}
-
-# Encrypt the file
-function encrypt {
-
-if [ "$ENCRYPT" = "yes" ]
- then
- if [ "$QUIET" != "yes" ]; then echo "Beginning file encryption. This should only take a few minutes.";echo; fi
- # Use the ticket number as the ssl keyfile name
- if [ ! /usr/bin/openssl ]; then
- echo "Cannot find openssl in /usr/bin. Terminating."; exit 1
- fi
- /usr/bin/openssl rand -out $ticket_number-$date.key -base64 48
- if [ "$QUIET" != "yes" ]; then
- echo "You have chosen to encrypt your core file. Your passkey file is"
- echo "$ticket_number-$date.key. Please attach this key to your ticket."
- echo
- fi
- /usr/bin/openssl aes-128-cbc -in $new_file -out $new_file.aes -pass file:$ticket_number-$date.key
-
-new_file="$new_file.aes"
-
-fi
-}
-
-function checksum {
-
-if [ "$CHECKSUM" = "yes" ]
- then
-
- if [ "$QUIET" != "yes" ]; then echo "Beginning $new_file checksum. This should only take a few minutes.";echo; fi
- if [ ! /usr/bin/md5sum ]; then
- echo "Cannot find md5sum in /usr/bin. Terminating."; exit 1
- fi
- md5result=`/usr/bin/md5sum $new_file|awk '{print $1}'`
- echo $md5result > $ticket_number-$date-checksum.out
-
-fi
-
-}
-
-function split {
-
-if [ "$SPLIT" = "0" ]; then return; fi
-
- hunk_size=$SPLIT
- if (( $hunk_size > 0 )) && (( $hunk_size < 1001 ))
- then
- if [ ! /usr/bin/split ]; then
- echo "Cannot find split in /usr/bin. Terminating."; exit 1
- fi
- # We need to make a directory to keep things sane
- if [ "$QUIET" != "yes" ]; then echo "Creating directory $ticket_number-$date to house file hunks"; fi
- /bin/mkdir $ticket_number-$date
- /usr/bin/split -b "$hunk_size"m -d $new_file $ticket_number-$date/$new_file
- else
- echo "Invalid hunk size argument. Please enter a number greater than 0 and less than 1001."
- echo "Terminating."; exit 1
- fi
-
-
-}
-
-function upload {
-
-if [ "$NOUPLOAD" = "yes" ]; then
- echo "All file operations are complete. The file(s) is ready to upload at your convenience."; return
- else
- echo "All file operation are complete. The file(s) is now ready to be uploaded."
- echo "Please enter the destination host (default is dropbox.redhat.com)"
- read destination_input
- if [ "$destination_input" != "" ]; then destination=$destination_input; fi
- if [ "$QUIET" != "yes" ]; then
- echo
- echo "Okay, uploading to $destination. Depending upon the file size and link throughput"
- echo "this could take quite a while. When the upload completes this script will provide"
- echo "additional information such as the md5sum, ssl key file, etc. and then exit."
- echo "Unless you do not have lftp installed you should be able to monitor upload status."
- echo "If lftp is not available then this script will exit and the core file(s) will need"
- echo "to be uploaded to your target system manually. The information indicated above"
- echo "will still be provided."
- echo
- fi
- if [ ! /usr/bin/lftp ]; then
- # No lftp installed
- echo "lftp could not be found in /usr/bin. The file(s) will need to be uploaded manually."
-
- else
- # Make the lftp script first
- echo "lftp $destination <<EOF" > lftp_scripts
- if [ "$SPLIT" = "yes" ]; then
- echo "lcd $ticket_number" >> lftp_scripts
- echo "mirror -R" >> lftp_scripts
- else
- echo "put $new_file" >> lftp_scripts
- fi
- echo "quit 0" >> lftp_scripts
- echo "EOF" >> lftp_scripts
- /usr/bin/lftp -f lftp_scripts
- fi
-fi
-}
-
-function closure {
-
-if [ "$ENCRYPT" = "yes" ] ; then
- echo
- echo " ## File was encrypted with $ticket_number-$date.key. Please upload the key"
- echo "to Issue Tracker or send it to your support representative for decryption"
- echo "after upload.";echo;
-fi
-
-
-if [ "$CHECKSUM" = "yes" ] ; then
- echo
- echo "## A checksum was performed on your core file (prior to splitting if you chose"
- echo "to do so)."
- echo
- echo "The checksum results are in:"
- echo "$ticket_number-$date-checksum.out."
- echo
- echo "Please include this when updating your trouble ticket so your support"
- echo "representative can verify the copy uploaded.";echo
-fi
-
-if [ "$SPLIT" != 0 ]; then
- echo
- echo "## Your core file was split and the hunks are in $ticket_number."
- echo
-fi
-
-echo "This script has completed successfully. If you performed file encryption and/or file"
-echo "splitting you may want to consider removing those files once your support representative"
-echo "confirms receipt. This will reduce the amount of space being utilised on your system."
-echo "It is NOT recommended to remove the gzipped copy of the core file."
-echo
-echo -en "\E[40;31m\033[3mThis would be the only remaining copy of the core file on your system.\033[0m"
-echo
-echo
-echo "It is recommended to retain the core file until your support representative indicates"
-echo "that the problem has been identified and/or resolved."
-
-}
-
-# Run through the functions
-repeat
-warn
-ticket
-file_ops
-compress
-encrypt
-checksum
-split
-upload
-closure
diff --git a/src/setup.py b/src/setup.py
index fe6d2c81..dceaba16 100644
--- a/src/setup.py
+++ b/src/setup.py
@@ -16,7 +16,7 @@ setup(
package_dir = {'': 'lib',},
data_files = [ ('/etc', [ 'sos.conf']),
('/usr/sbin', ['sosreport', 'extras/sysreport/sysreport.legacy']),
- ('/usr/bin', ['extras/rh-upload-core']),
+ ('/usr/bin', ['extras/rh-upload']),
('/usr/share/sos/',['gpgkeys/rhsupport.pub']),
('/usr/share/sysreport', ['extras/sysreport/text.xsl', 'extras/sysreport/functions', 'extras/sysreport/sysreport-fdisk']),
('/usr/share/man/man1', ['sosreport.1.gz']),
diff --git a/src/sos.spec b/src/sos.spec
index fc549d6b..2f2f7dc0 100644
--- a/src/sos.spec
+++ b/src/sos.spec
@@ -3,7 +3,7 @@
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
Version: 1.8
-Release: 14%{?dist}
+Release: 15%{?dist}
Group: Applications/System
Source0: https://fedorahosted.org/releases/s/o/sos/%{name}-%{version}.tar.gz
License: GPLv2+
@@ -41,7 +41,7 @@ rm -rf ${RPM_BUILD_ROOT}
%files -f %{name}.lang
%defattr(-,root,root,-)
-%{_bindir}/rh-upload-core
+%{_bindir}/rh-upload
%{_sbindir}/sosreport
%{_sbindir}/sysreport
%{_sbindir}/sysreport.legacy
@@ -49,10 +49,13 @@ rm -rf ${RPM_BUILD_ROOT}
%{_datadir}/sysreport
%{python_sitelib}/*
%{_mandir}/man1/sosreport.1.gz
-%doc README README.rh-upload-core TODO LICENSE ChangeLog
+%doc README README.rh-upload TODO LICENSE ChangeLog
%config %{_sysconfdir}/sos.conf
%changelog
+* Tue Sep 9 2009 Adam Stokes <ajs at redhat dot com> = 1.8-15
+- Update rh-upload-core to rh-upload and allows general files
+
* Thu Jul 23 2009 Adam Stokes <ajs at redhat dot com> = 1.8-14
- resolves: rhbz512536 wrong group in spec file
- resolves: rhbz498398 A series of refactoring patches to sos