]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
util/dovecot-sysreport --core: Support multiple core files
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 1 Apr 2021 11:16:34 +0000 (14:16 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 7 May 2021 19:31:00 +0000 (19:31 +0000)
doc/man/dovecot-sysreport.1.in
src/util/dovecot-sysreport

index bd736215b3ec84e2cd099cc2509213025d1bc36f..e3b30cebf39acb18ea16f0a185d918804d1631a4 100644 (file)
@@ -4,8 +4,8 @@
 dovecot-sysreport \- Dovecot\(aqs system report utility
 .\"------------------------------------------------------------------------
 .SH SYNOPSIS
-.BR dovecot-sysreport " [" \-h|\-\-help "] [" \-c|\-\-core
-.IR binary " " core "]
+.BR dovecot-sysreport " [" \-h|\-\-help "] [" \-c|\-\-core " ["\c
+.IR binary "] " core " [...]]"
 .BR "[\-d|\-\-destination
 .IR dest "]
 .BR "[\-k|\-\-keeptemp]
@@ -27,8 +27,8 @@ Prints a help message.
 Sets the root file of the dovecot's configuration. If not set, it will be
 assumed to be in the default configuration path.
 .TP
-.BI \-o|\-\-core\  "binary\  core"
-Includes a core file along with its dependencies extracted from the
+.BI \-o|\-\-core\ [ binary "] " core " [...]]"
+Includes core files along with their dependencies extracted from the
 specified binary file.
 .TP
 .BI \-d|\-\-destination\  dest
index 63ef57e4e48723f5902afc4294d1f69df1465d30..525a3fdfb504f729e1d84ca9d960844fc7275752 100755 (executable)
@@ -6,7 +6,7 @@ dest="dovecot-sysreport-$(uname -n)-$(date +'%s').tar.gz"
 conf_flag=""
 binary=""
 core=""
-core_files=""
+copy_files=""
 keep_temp=0
 
 PARAMS=""
@@ -48,39 +48,42 @@ while (( "$#" )); do
       fi
 
       if [[ "$#" -lt 2 ]] ; then
-        echo "Usage: $0 $1 [<binary>] <core>"
+        echo "Usage: $0 $1 [<binary>] <core> [...]"
         exit 1
       fi
 
-      # see if binary parameter is specified
-      binary=$2
-      if ! [ -r "$binary" ]; then
-        echo "$binary not readable"
-        exit 1
-      fi
-      binary_info=$(file "$binary")
-      if echo "$binary_info" | grep "core file.*execfn: '" >/dev/null; then
-        # no binary specified - detect it
-       binary=$(echo "$binary_info" | sed "s;^.*execfn: '\([^\']\+\)'.*$;\1;")
+      while [[ "$#" -ge 2 ]]; do
+       # see if binary parameter is specified
+       binary=$2
        if ! [ -r "$binary" ]; then
-         echo "Detected binary path '$binary' from core file, but it is not readable"
+         echo "$binary not readable"
          exit 1
        fi
-       echo "Core file was detected to be generated by $binary"
-      else
-       shift
-      fi
+       binary_info=$(file "$binary")
+       if echo "$binary_info" | grep "core file.*execfn: '" >/dev/null; then
+         # no binary specified - detect it
+         binary=$(echo "$binary_info" | sed "s;^.*execfn: '\([^\']\+\)'.*$;\1;")
+         if ! [ -r "$binary" ]; then
+           echo "Detected binary path '$binary' from core file, but it is not readable"
+           exit 1
+         fi
+         echo "Core file was detected to be generated by $binary"
+       else
+         shift
+       fi
 
-      core=$2
-      shift
-      if ! [ -s "$core" ]; then
-        echo "$core not found or it is empty"
-        exit 1
-      fi
+       core=$2
+       shift
+       if ! [ -s "$core" ]; then
+         echo "$core not found or it is empty"
+         exit 1
+       fi
 
-      echo "gathering core file dependencies..."
-      core_files=$((echo "info shared"; sleep 1) | $gdb $binary $core | grep '^0x.*/' | sed 's,^[^/]*,,')
-      cp $core $SRTEMP
+       echo "gathering core file dependencies..."
+       core_files=$((echo "info shared"; sleep 1) | $gdb $binary $core | grep '^0x.*/' | sed 's,^[^/]*,,')
+       copy_files="$copy_files $binary $core_files"
+       cp $core $SRTEMP
+      done
       shift
       ;;
 
@@ -92,7 +95,7 @@ while (( "$#" )); do
 
     -h|--help)
 
-      echo -e "dovecot-sysreport \t[-h|--help] [-c|--core [binary] core] [-d|--destination dest]
+      echo -e "dovecot-sysreport \t[-h|--help] [-c|--core [binary] core [...]] [-d|--destination dest]
       \t\t\t[-k|--keeptemp] -- utility to gather information from the current
       \t\t\tsystem to be reported for dovecot bug fixes."
       echo ""
@@ -193,7 +196,7 @@ cf=`pwd`
 cd $SRTEMP
 echo "Creating archive ..."
 tar -czf `if [[ "$dest" = /* ]]; then echo $dest; else echo $cf/$dest; fi` --dereference \
-  $binary $core_files *
+  $copy_files *
 
 function cleanup {
   if [ $keep_temp = 0 ]; then