qubes-hcl-report 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 |cut -d '.' -f-3`
  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. HVM="good"
  61. VTD="Active"
  62. IOMMU="good"
  63. elif [[ "$XLINFO" =~ "hvm" ]]
  64. then
  65. VTX="Active"
  66. HVM="good"
  67. VTD="Not Active"
  68. IOMMU="bad"
  69. else
  70. VTX="Not Active"
  71. HVM="bad"
  72. VTD="Not Active"
  73. IOMMU="bad"
  74. fi
  75. sudo cat /etc/qubes-release |tee ~/$FILENAME.txt
  76. echo
  77. echo -e "Model Name:\t$BRAND $PRODUCT" |tee -a ~/$FILENAME.txt
  78. echo -e "Kernel:\t\t$KERNEL" |tee -a ~/$FILENAME.txt
  79. echo -e "Xen:\t\t$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA\n" |tee -a ~/$FILENAME.txt
  80. echo -e "CPU:\t\t$CPU" |tee -a ~/$FILENAME.txt
  81. echo -e "Chipset:\t$CHIPSET" |tee -a ~/$FILENAME.txt
  82. echo -e "VGA:$VGA\n" |tee -a ~/$FILENAME.txt
  83. echo -e "BIOS:\t\t$BIOS" |tee -a ~/$FILENAME.txt
  84. echo -e "VT-x:\t\t$VTX" |tee -a ~/$FILENAME.txt
  85. echo -e "VT-d:\t\t$VTD" |tee -a ~/$FILENAME.txt
  86. echo
  87. echo -e "
  88. >-->-->-->-->--> HCL Wiki format begins >-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->
  89. <!--
  90. Insert devices in alphabetical order.
  91. Change hcl-FIXME to appropriate class (see legend):
  92. hcl-good, hcl-bad, hcl-partial, hcl-unknown
  93. Go to https://groups.google.com/forum/#!forum/qubes-users and search
  94. the message containing the HCL report.
  95. Then click on "more message options" besides reply button and then on
  96. link and insert it into FIXLINK.
  97. -->
  98. <tr align='center'>
  99. <td rowspan='1'>
  100. $BRAND $PRODUCT<br>
  101. (CPU, Chipset, embedded VGA)
  102. </td>
  103. <td rowspan='1'>${BIOS}</td>\t\t\t\t<!-- BIOS version\t\t# reported BIOS version -->
  104. <td rowspan='1' class='hcl-${HVM}'></td>\t\t\t<!-- HVM\t\t\t# HVM can be created? -->
  105. <td rowspan='1' class='hcl-${IOMMU}'></td>\t\t\t<!-- IOMMU\t\t\t# PCI-Devices can be assigned to a HVM? -->
  106. <td rowspan='1' class='hcl-unknown'></td>\t\t<!-- TPM\t\t\t# Anti Evil Made works? -->
  107. <td rowspan='1'></td>\t\t\t\t\t<!-- spacing (QSL) -->\t\t# best achievable QSL - (Qubes Security Level) -->
  108. <td rowspan='1' class='hcl-FIXME'>R2</td>\t\t<!-- Qubes version\t\t# first reported Qubes version -->
  109. <td rowspan='1' class='hcl-FIXME'>${KERNEL}</td>\t<!-- dom0 kernel\t\t# Boots with this kernel version (refer to exact kernel version). -->
  110. <td rowspan='1' class='hcl-FIXME'>\n \n </td>\t\t\t\t\t\t\t<!-- Remarks -->
  111. <td rowspan='1' class='hcl-reportedby'>
  112. <a class='ext-link' href='FIXLINK'><span class='icon'></span>insert name</a>
  113. </td>\t\t\t\t\t\t\t<!-- Reported by -->
  114. </tr>
  115. <!--
  116. If you add a report to an existing device increment the rowspan of
  117. first entry for Device, BIOS, HVM, IOMMU, TPM, spacing(QSL)
  118. and append the following with the new report data filled in:
  119. -->
  120. <tr align='center'>
  121. <td rowspan='1' class='hcl-FIXME'>R2</td>\t\t<!-- Qubes version\t\t# latest reported Qubes version -->
  122. <td rowspan='1' class='hcl-FIXME'>${KERNEL}</td>\t<!-- dom0 kernel\t\t# Boots with this kernel version (refer to exact kernel version). -->
  123. <td rowspan='1' class='hcl-FIXME'>\n \n </td>\t\t\t\t\t\t\t<!-- Remarks -->
  124. <td rowspan='1' class='hcl-reportedby'>
  125. <a class='ext-link' href='FIXLINK'><span class='icon'></span>insert name</a>
  126. </td>\t\t\t\t\t\t\t<!-- Reported by -->
  127. </tr>
  128. " >> ~/$FILENAME.txt
  129. TEMP_DIR=`mktemp -d`
  130. sudo cat /etc/qubes-release > $TEMP_DIR/qubes-release
  131. sudo cat /proc/cpuinfo > $TEMP_DIR/cpuinfo
  132. sudo lspci -nnvk > $TEMP_DIR/lspci
  133. sudo dmidecode > $TEMP_DIR/dmidecode
  134. sudo xl info > $TEMP_DIR/xl
  135. # cpio
  136. cd $TEMP_DIR
  137. find -print0 |cpio --quiet -o -H crc --null |gzip >~/$FILENAME.cpio.gz
  138. cd
  139. # VM check
  140. if [[ "$COPY2VM" != "dom0" ]]
  141. then
  142. # Copy to VM
  143. qvm-start -q $COPY2VM 2>/dev/null
  144. cat ~/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz"
  145. cat ~/$FILENAME.txt | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.txt"
  146. fi
  147. echo -e "Qubes HCL Support files are copied to: '$COPY2VM'"
  148. echo -e "\t$FILENAME.txt\t\t- HCL Info"
  149. echo -e "\t$FILENAME.cpio.gz\t- HCL Support Files"
  150. # cleanup
  151. if [[ -d $TEMP_DIR ]]
  152. then
  153. rm -rf $TEMP_DIR
  154. fi