qubes-hcl-report 6.6 KB

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