qubes-hcl-report 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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`
  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. FILENAME="Qubes-HCL-$BRAND-$PRODUCT-$DATE"
  54. if [[ "$XLINFO" =~ "hvm_directio" ]]
  55. then
  56. VTX="Active"
  57. VTD="Active"
  58. elif [[ "$XLINFO" =~ "hvm" ]]
  59. then
  60. VTX="Active"
  61. VTD="Not Active"
  62. else
  63. VTX="Not Active"
  64. VTD="Not Active"
  65. fi
  66. sudo cat /etc/qubes-release |tee ~/$FILENAME.txt
  67. echo
  68. echo -e "Model Name:\t$BRAND $PRODUCT" |tee -a ~/$FILENAME.txt
  69. echo -e "Kernel:\t\t$KERNEL\n" |tee ~/$FILENAME.txt
  70. echo -e "CPU:\t\t$CPU" |tee -a ~/$FILENAME.txt
  71. echo -e "Chipset:\t$CHIPSET" |tee -a ~/$FILENAME.txt
  72. echo -e "VGA:$VGA\n" |tee -a ~/$FILENAME.txt
  73. echo -e "BIOS:\t\t$BIOS" |tee -a ~/$FILENAME.txt
  74. echo -e "VT-x:\t\t$VTX" |tee -a ~/$FILENAME.txt
  75. echo -e "VT-d:\t\t$VTD" |tee -a ~/$FILENAME.txt
  76. echo
  77. TEMP_DIR=`mktemp -d`
  78. sudo cat /etc/qubes-release > $TEMP_DIR/qubes-release
  79. sudo cat /proc/cpuinfo > $TEMP_DIR/cpuinfo
  80. sudo lspci -nnvk > $TEMP_DIR/lspci
  81. sudo dmidecode > $TEMP_DIR/dmidecode
  82. sudo xl info > $TEMP_DIR/xl
  83. # cpio
  84. cd $TEMP_DIR
  85. find -print0 |cpio --quiet -o -H crc --null |gzip >~/$FILENAME.cpio.gz
  86. cd
  87. # VM check
  88. if [[ "$COPY2VM" != "dom0" ]]
  89. then
  90. # Copy to VM
  91. qvm-start -q $COPY2VM 2>/dev/null
  92. cat ~/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz"
  93. cat ~/$FILENAME.txt | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.txt"
  94. fi
  95. echo -e "Qubes HCL Support files are copied to: '$COPY2VM'"
  96. echo -e "\t$FILENAME.txt\t\t- HCL Info"
  97. echo -e "\t$FILENAME.cpio.gz\t- HCL Support Files"
  98. # cleanup
  99. if [[ -d $TEMP_DIR ]]
  100. then
  101. rm -rf $TEMP_DIR
  102. fi