qubes-hcl-report 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. VERSION=2.2
  20. COPY2VM="dom0"
  21. SUPPORT_FILES=0
  22. while [ $# -gt 0 ]; do
  23. case "$1" in
  24. -s |--support)
  25. SUPPORT_FILES=1
  26. ;;
  27. -* | -h | --help)
  28. echo -e "qubes-hcl-report v$VERSION"
  29. echo ""
  30. echo "This tool is used to gather basic hardware information for the Qubes HCL (Hardware Compatibility List)"
  31. echo "and copy the results to the given AppVM for the easy contribution."
  32. echo ""
  33. echo -e "Usage:\tqubes-hcl-report [OPTIONS] [<AppVM Name>]"
  34. echo -e "Options are:"
  35. echo -e "\t-h, --help\tDisplay this help text and exit."
  36. echo -e "\t-s, --support\tGenerate more detailed HCL Support Files"
  37. echo -e "\t\t\tWARNING: The HCL Support Files may contain numerous hardware details, including serial numbers."
  38. echo -e "\t\t\tIf, for privacy or security reasons, you do not wish to make this information public, "
  39. echo -e "\t\t\tplease do not send the .cpio.gz file to the public mailing list."
  40. echo ""
  41. echo -e "\t<AppVM Name>\tCopy the results to the given AppVM. The default is to keep it in dom0"
  42. echo ""
  43. exit
  44. ;;
  45. *)
  46. /usr/bin/qvm-check -q $1
  47. if [[ $? -eq 0 ]]
  48. then
  49. COPY2VM="$1"
  50. else
  51. echo -e "ERROR:\tAppVM with the name '$1' does not exist in the system!"
  52. exit 1
  53. fi
  54. ;;
  55. esac
  56. shift
  57. done
  58. DATE=`date +%Y%m%d-%H%M%S`
  59. TEMP_DIR=`mktemp --tmpdir -d HCL.XXXXXXXXXX`
  60. cat /etc/qubes-release > $TEMP_DIR/qubes-release
  61. cat /proc/cpuinfo > $TEMP_DIR/cpuinfo
  62. lspci -nnvk > $TEMP_DIR/lspci
  63. cat /proc/scsi/scsi > $TEMP_DIR/scsi
  64. sudo dmidecode > $TEMP_DIR/dmidecode
  65. xl info > $TEMP_DIR/xl-info
  66. xl dmesg > $TEMP_DIR/xl-dmesg
  67. BRAND=`cat $TEMP_DIR/dmidecode |grep -A9 "System Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _`
  68. PRODUCT=`cat $TEMP_DIR/dmidecode |grep -A9 "System Information" |grep "Product Name:" |cut -d ' ' -f3- |tr -s '[:blank:]' _`
  69. if [[ $BRAND =~ "O.E.M" ]]
  70. then
  71. BRAND=`cat $TEMP_DIR/dmidecode |grep -A9 "Base Board Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _`
  72. PRODUCT=`cat $TEMP_DIR/dmidecode |grep -A9 "Base Board Information" |grep "Product Name:" |cut -d ' ' -f3- |tr -s '[:blank:]' _`
  73. fi
  74. KERNEL=`uname -r |cut -d '.' -f-3`
  75. CPU=`cat $TEMP_DIR/cpuinfo |grep "model name" |sort -u |cut -d ' ' -f3-`
  76. CHIPSET=`cat $TEMP_DIR/lspci |grep "00:00.0.*Host bridge"`
  77. VGA=`cat $TEMP_DIR/lspci |grep "VGA\|Display" | sed -e "s/^/\t\t/"`
  78. NET=`cat $TEMP_DIR/lspci |lspci |grep "Network\|Ethernet" |sed -e "s/^/\t\t/"`
  79. SCSI=`cat $TEMP_DIR/scsi |grep Model |cut -d ':' -f3- | sed -e "s/^[[:space:]]*/\t\t/"`
  80. RAM=`cat $TEMP_DIR/xl-info |grep total_memory |cut -d ':' -f2 |tr -d ' '`
  81. BIOS=`cat $TEMP_DIR/dmidecode |grep -A9 "BIOS Information" |grep "Version" |cut -d ' ' -f2-`
  82. XEN_MAJOR=`cat $TEMP_DIR/xl-info |grep xen_major |cut -d: -f2 |tr -d ' '`
  83. XEN_MINOR=`cat $TEMP_DIR/xl-info |grep xen_minor |cut -d: -f2 |tr -d ' '`
  84. XEN_EXTRA=`cat $TEMP_DIR/xl-info |grep xen_extra |cut -d: -f2 |tr -d ' '`
  85. XL_VTX=`cat $TEMP_DIR/xl-info |grep xen_caps | grep hvm`
  86. XL_VTD=`cat $TEMP_DIR/xl-info |grep virt_caps |grep hvm_directio`
  87. FILENAME="Qubes-HCL-$BRAND-$PRODUCT-$DATE"
  88. if [[ $XL_VTX ]]
  89. then
  90. VTX="Active"
  91. HVM="good"
  92. else
  93. VTX="Not Active"
  94. HVM="bad"
  95. fi
  96. if [[ $XL_VTD ]]
  97. then
  98. VTD="Active"
  99. IOMMU="good"
  100. else
  101. VTD="Not Active"
  102. IOMMU="bad"
  103. fi
  104. cat /etc/qubes-release |tee $HOME/$FILENAME.txt
  105. echo
  106. echo -e "Model Name:\t$BRAND $PRODUCT" |tee -a $HOME/$FILENAME.txt
  107. echo -e "Kernel:\t\t$KERNEL" |tee -a $HOME/$FILENAME.txt
  108. echo -e "Xen:\t\t$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA\n" |tee -a $HOME/$FILENAME.txt
  109. echo -e "RAM:\t\t$RAM Mb\n" |tee -a $HOME/$FILENAME.txt
  110. echo -e "CPU:\t\t$CPU" |tee -a $HOME/$FILENAME.txt
  111. echo -e "Chipset:\t$CHIPSET" |tee -a $HOME/$FILENAME.txt
  112. echo -e "VGA:$VGA\n" |tee -a $HOME/$FILENAME.txt
  113. echo -e "Net:$NET\n" |tee -a $HOME/$FILENAME.txt
  114. echo -e "SCSI:$SCSI\n" |tee -a $HOME/$FILENAME.txt
  115. echo -e "BIOS:\t\t$BIOS" |tee -a $HOME/$FILENAME.txt
  116. echo -e "VT-x:\t\t$VTX" |tee -a $HOME/$FILENAME.txt
  117. echo -e "VT-d:\t\t$VTD" |tee -a $HOME/$FILENAME.txt
  118. echo
  119. echo -e "
  120. >-->-->-->-->--> HCL Wiki format begins >-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->
  121. <!--
  122. Insert devices in alphabetical order.
  123. Change hcl-FIXME to appropriate class (see legend):
  124. hcl-good, hcl-bad, hcl-partial, hcl-unknown
  125. Go to https://groups.google.com/forum/#!forum/qubes-users and search
  126. the message containing the HCL report.
  127. Then click on "more message options" besides reply button and then on
  128. link and insert it into FIXLINK.
  129. -->
  130. <tr align='center'>
  131. <td rowspan='1'>
  132. $BRAND $PRODUCT<br>
  133. (CPU, Chipset, embedded VGA)
  134. </td>
  135. <td rowspan='1'>${BIOS}</td>\t\t\t\t<!-- BIOS version\t\t# reported BIOS version -->
  136. <td rowspan='1' class='hcl-${HVM}'></td>\t\t\t<!-- HVM\t\t\t# HVM can be created? -->
  137. <td rowspan='1' class='hcl-${IOMMU}'></td>\t\t\t<!-- IOMMU\t\t\t# PCI-Devices can be assigned to a HVM? -->
  138. <td rowspan='1' class='hcl-unknown'></td>\t\t<!-- TPM\t\t\t# Anti Evil Made works? -->
  139. <td rowspan='1'></td>\t\t\t\t\t<!-- spacing (QSL)\t\t# best achievable QSL - (Qubes Security Level) -->
  140. <td rowspan='1' class='hcl-FIXME'>R2</td>\t\t<!-- Qubes version\t\t# first reported Qubes version -->
  141. <td rowspan='1' class='hcl-FIXME'>${KERNEL}</td>\t<!-- dom0 kernel\t\t# Boots with this kernel version (refer to exact kernel version). -->
  142. <td rowspan='1' class='hcl-FIXME'>\n \n </td>\t\t\t\t\t\t\t<!-- Remarks -->
  143. <td rowspan='1' class='hcl-reportedby'>
  144. <a class='ext-link' href='FIXLINK'><span class='icon'></span>insert name</a>
  145. </td>\t\t\t\t\t\t\t<!-- Reported by -->
  146. </tr>
  147. <!--
  148. If you add a report to an existing device increment the rowspan of
  149. first entry for Device, BIOS, HVM, IOMMU, TPM, spacing(QSL)
  150. and append the following with the new report data filled in:
  151. -->
  152. <tr align='center'>
  153. <td rowspan='1' class='hcl-FIXME'>R2</td>\t\t<!-- Qubes version\t\t# latest reported Qubes version -->
  154. <td rowspan='1' class='hcl-FIXME'>${KERNEL}</td>\t<!-- dom0 kernel\t\t# Boots with this kernel version (refer to exact kernel version). -->
  155. <td rowspan='1' class='hcl-FIXME'>\n \n </td>\t\t\t\t\t\t\t<!-- Remarks -->
  156. <td rowspan='1' class='hcl-reportedby'>
  157. <a class='ext-link' href='FIXLINK'><span class='icon'></span>insert name</a>
  158. </td>\t\t\t\t\t\t\t<!-- Reported by -->
  159. </tr>
  160. " >> $HOME/$FILENAME.txt
  161. if [[ "$SUPPORT_FILES" == 1 ]]
  162. then
  163. # cpio
  164. cd $TEMP_DIR
  165. find -print0 |cpio --quiet -o -H crc --null |gzip >$HOME/$FILENAME.cpio.gz
  166. cd
  167. fi
  168. # Destination VM check
  169. if [[ "$COPY2VM" != "dom0" ]]
  170. then
  171. # Copy to VM
  172. qvm-start -q $COPY2VM 2>/dev/null
  173. if [[ -f "$HOME/$FILENAME.cpio.gz" ]]
  174. then
  175. cat $HOME/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz"
  176. fi
  177. if [[ -f "$HOME/$FILENAME.txt" ]]
  178. then
  179. cat $HOME/$FILENAME.txt | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.txt"
  180. fi
  181. fi
  182. echo -e "Qubes HCL Files are copied to: '$COPY2VM'"
  183. echo -e "\t$FILENAME.txt\t\t- HCL Info"
  184. if [[ "$SUPPORT_FILES" == 1 ]]
  185. then
  186. echo -e "\t$FILENAME.cpio.gz\t- HCL Support Files"
  187. fi
  188. echo
  189. # cleanup
  190. if [[ -d $TEMP_DIR ]]
  191. then
  192. rm -rf $TEMP_DIR
  193. fi