]> xenbits.xen.org Git - xenclient/build.git/commitdiff
[xenclient/skeleton] Make bugtool a bit more user friendly.
authorJean Guyader <jean.guyader@eu.citrix.com>
Thu, 10 Sep 2009 16:19:03 +0000 (17:19 +0100)
committerJean Guyader <jean.guyader@eu.citrix.com>
Thu, 10 Sep 2009 16:19:03 +0000 (17:19 +0100)
         XC-212: fixed

target/generic/target_xenclient_skeleton/usr/bin/bugtool

index 47b7105f80d68b1064e27e1287777db404f3457b..a5f16c5c10b0b153bae1f38b8894c77535471ab3 100755 (executable)
@@ -1,40 +1,79 @@
 #! /bin/sh -e
 
 name="`basename $0`"
+d="`date "+%Y%m%d%H%M%S"`"
+
+saved_tarball="/tmp/$name/$name-$d.tar.bz2"
+base_path="`dirname "$saved_tarball"`/`basename "$saved_tarball" .tar.bz2`"
+
 files=""
 
+welcome()
+{
+cat <<EOF
+XenClient $name
+
+This application will collate the Xen dmesg output, details of the
+hardware configuration of your machine, information about the build of
+Xen that you are using, plus, if you allow it, various logs.
+
+The collated information will be saved as a .tar.bz2 for archiving or
+sending to a Technical Support Representative.
+
+To copy the file away from the host a command like scp or ftpput could
+be used.
+        scp <local-file> <remote-user>@<remote-host>:<remote-file>
+        ftpput <remote-host> <remote-file> <local-file>
+
+The logs may contain private information, and if you are at all
+worried about that, you should exit now, or you should explicitly
+exclude those logs from the archive.
+
+EOF
+}
+
+archive()
+{
+        local out="$1"
+        local files="$2"
+
+        tar -cfO $files | bzip2 -z -c > "$out"
+}
+
 save_file()
 {
-        save_path="$1"
-        save_file="$2"
-        save_out="$3"
+        local save_path="$1"
+        local save_file="$2"
+        local save_out="$3"
 
         cd "$save_path"
-        tar -cvf "/tmp/${save_out}.tar" $save_file > ${name}.log
-        bzip2 -f "/tmp/${save_out}.tar"
+        archive "${base_path}/${save_out}.tar.bz2" $save_file > ${base_path}/${name}.log 2>&1
         files="$files ${save_out}.tar.bz2"
         cd - > /dev/null
 }
 
 save_out()
 {
-        save_out_cmd="$1"
-        save_out_out="$2"
+        local save_out_cmd="$1"
+        local save_out_out="$2"
 
-        $save_out_cmd > /tmp/${save_out_out}.log 2>&1
+        $save_out_cmd > "${base_path}/${save_out_out}.log" 2>&1
         files="$files ${save_out_out}.log"
 }
 
 bugtool_file()
 {
-        cd "/tmp"
-        tar -cf /tmp/${name}.tar $files ${name}.log
-        bzip2 -f /tmp/${name}.tar
-        ls -lah "${name}.tar.bz2"
-        rm -f $files
+        local base="$1"
+
+        cd "${base_path}"
+        archive "${saved_tarball}" "$files ${name}.log"
         cd - > /dev/null
+        rm -rf "${base_path}"
 }
 
+welcome
+
+mkdir -p "${base_path}"
 save_file "/var/log" "messages*" "syslog"
 save_file "/config/vms" "*" "vms"
 save_file "/var/log" "xenstored-access*" "xenstored-access"
@@ -45,6 +84,7 @@ save_out "dmidecode" "dmidecode"
 save_out "xenops list" "xenops_list"
 save_out "brctl show" "brctl_show"
 save_out "ifconfig" "ifconfig"
-
-bugtool_file
+bugtool_file "/tmp/$name/$name-$d"
 sync
+
+echo "Writing tarball ${saved_tarball} successful."