qubes-hcl-report 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/bash
  2. # The Qubes OS Project, http://www.qubes-os.org
  3. #
  4. # Copyright (C) 2013 Laszlo Zrubecz <mail@zrubi.hu>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. if [[ -z "$1" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "-q" ]]
  20. then
  21. echo ""
  22. echo "This tool is used to gather hardware information for the Qubes HCL (Hardware Compatibility List)"
  23. echo "and copy the Support Files to the given AppVM for the easy contribution..."
  24. echo "If you do not want to copy them to any AppVM use 'dom0' as AppVM Name."
  25. echo ""
  26. echo -e "Usage:\tqubes-hcl-report <AppVM Name>"
  27. echo ""
  28. exit
  29. else
  30. /usr/bin/qvm-check -q $1
  31. if [[ $? -eq 0 ]]
  32. then
  33. COPY2VM="$1"
  34. else
  35. echo -e "ERROR:\tAppVM with the name '$1' does not exist in the system!"
  36. exit 1
  37. fi
  38. fi
  39. DATE=`date +%Y%m%d-%H%M%S`
  40. BRAND=`sudo dmidecode |grep -A9 "System Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _`
  41. PRODUCT=`sudo dmidecode |grep -A9 "System Information" |grep "Product Name:" |cut -d ' ' -f3- |tr -s '[:blank:]' _`
  42. if [[ $BRAND =~ "O.E.M" ]]
  43. then
  44. BRAND=`sudo dmidecode |grep -A9 "Base Board Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _`
  45. PRODUCT=`sudo dmidecode |grep -A9 "Base Board Information" |grep "Product Name:" |cut -d ' ' -f3- |tr -s '[:blank:]' _`
  46. fi
  47. KERNEL=`uname -r`
  48. CPU=`sudo cat /proc/cpuinfo |grep "model name" |sort -u |cut -d ' ' -f3-`
  49. CHIPSET=`sudo lspci -nn |grep "00:00.0.*Host bridge"`
  50. VGA=`sudo lspci -nn |grep "VGA\|Display" | sed -e "s/^/\t\t/"`
  51. BIOS=`sudo dmidecode |grep -A9 "BIOS Information" |grep "Version" |cut -d ' ' -f2-`
  52. XLINFO=`sudo xl info |grep "virt_caps"`
  53. XEN_MAJOR=`sudo xl info |grep xen_major |cut -d: -f2 |tr -d ' '`
  54. XEN_MINOR=`sudo xl info |grep xen_minor |cut -d: -f2 |tr -d ' '`
  55. XEN_EXTRA=`sudo xl info |grep xen_extra |cut -d: -f2 |tr -d ' '`
  56. FILENAME="Qubes-HCL-$BRAND-$PRODUCT-$DATE"
  57. if [[ "$XLINFO" =~ "hvm_directio" ]]
  58. then
  59. VTX="Active"
  60. VTD="Active"
  61. elif [[ "$XLINFO" =~ "hvm" ]]
  62. then
  63. VTX="Active"
  64. VTD="Not Active"
  65. else
  66. VTX="Not Active"
  67. VTD="Not Active"
  68. fi
  69. sudo cat /etc/qubes-release |tee ~/$FILENAME.txt
  70. echo
  71. echo -e "Model Name:\t$BRAND $PRODUCT" |tee -a ~/$FILENAME.txt
  72. echo -e "Kernel:\t\t$KERNEL" |tee -a ~/$FILENAME.txt
  73. echo -e "Xen:\t\t$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA\n" |tee -a ~/$FILENAME.txt
  74. echo -e "CPU:\t\t$CPU" |tee -a ~/$FILENAME.txt
  75. echo -e "Chipset:\t$CHIPSET" |tee -a ~/$FILENAME.txt
  76. echo -e "VGA:$VGA\n" |tee -a ~/$FILENAME.txt
  77. echo -e "BIOS:\t\t$BIOS" |tee -a ~/$FILENAME.txt
  78. echo -e "VT-x:\t\t$VTX" |tee -a ~/$FILENAME.txt
  79. echo -e "VT-d:\t\t$VTD" |tee -a ~/$FILENAME.txt
  80. echo
  81. TEMP_DIR=`mktemp -d`
  82. sudo cat /etc/qubes-release > $TEMP_DIR/qubes-release
  83. sudo cat /proc/cpuinfo > $TEMP_DIR/cpuinfo
  84. sudo lspci -nnvk > $TEMP_DIR/lspci
  85. sudo dmidecode > $TEMP_DIR/dmidecode
  86. sudo xl info > $TEMP_DIR/xl
  87. # cpio
  88. cd $TEMP_DIR
  89. find -print0 |cpio --quiet -o -H crc --null |gzip >~/$FILENAME.cpio.gz
  90. cd
  91. # VM check
  92. if [[ "$COPY2VM" != "dom0" ]]
  93. then
  94. # Copy to VM
  95. qvm-start -q $COPY2VM 2>/dev/null
  96. cat ~/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz"
  97. cat ~/$FILENAME.txt | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.txt"
  98. fi
  99. echo -e "Qubes HCL Support files are copied to: '$COPY2VM'"
  100. echo -e "\t$FILENAME.txt\t\t- HCL Info"
  101. echo -e "\t$FILENAME.cpio.gz\t- HCL Support Files"
  102. # cleanup
  103. if [[ -d $TEMP_DIR ]]
  104. then
  105. rm -rf $TEMP_DIR
  106. fi