191 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			191 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| 
 | |
| # The Qubes OS Project, http://www.qubes-os.org
 | |
| #
 | |
| # Copyright (C) 2013  Laszlo Zrubecz <mail@zrubi.hu>
 | |
| #
 | |
| # This program is free software; you can redistribute it and/or
 | |
| # modify it under the terms of the GNU General Public License
 | |
| # as published by the Free Software Foundation; either version 2
 | |
| # of the License, or (at your option) any later version.
 | |
| #
 | |
| # This program is distributed in the hope that it will be useful,
 | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
| # GNU General Public License for more details.
 | |
| #
 | |
| # You should have received a copy of the GNU General Public License
 | |
| # along with this program; if not, write to the Free Software
 | |
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 | |
| 
 | |
| if [[ -z "$1" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "-q" ]]
 | |
|  then
 | |
|     echo ""
 | |
|     echo "This tool is used to gather hardware information for the Qubes HCL (Hardware Compatibility List)"
 | |
|     echo "and copy the Support Files to the given AppVM for the easy contribution..."
 | |
|     echo "If you do not want to copy them to any AppVM use 'dom0' as AppVM Name."
 | |
|     echo ""
 | |
|     echo -e "Usage:\tqubes-hcl-report <AppVM Name>"
 | |
|     echo ""
 | |
|     exit
 | |
| 
 | |
| else
 | |
|     /usr/bin/qvm-check -q $1
 | |
|     if [[ $? -eq 0 ]]
 | |
|      then
 | |
|         COPY2VM="$1"
 | |
|     else
 | |
|         echo -e "ERROR:\tAppVM with the name '$1' does not exist in the system!"
 | |
|         exit 1
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| DATE=`date +%Y%m%d-%H%M%S`
 | |
| 
 | |
| BRAND=`sudo dmidecode |grep -A9 "System Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _`
 | |
| PRODUCT=`sudo dmidecode |grep -A9 "System Information" |grep "Product Name:" |cut -d ' ' -f3- |tr -s '[:blank:]' _`
 | |
| 
 | |
| if [[ $BRAND =~ "O.E.M" ]]
 | |
|  then
 | |
|     BRAND=`sudo dmidecode |grep -A9 "Base Board Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _`
 | |
|     PRODUCT=`sudo dmidecode |grep -A9 "Base Board Information" |grep "Product Name:" |cut -d ' ' -f3- |tr -s '[:blank:]' _`
 | |
| fi
 | |
| 
 | |
| KERNEL=`uname -r |cut -d '.' -f-3`
 | |
| CPU=`sudo cat /proc/cpuinfo |grep "model name" |sort -u |cut -d ' ' -f3-`
 | |
| CHIPSET=`sudo lspci -nn |grep "00:00.0.*Host bridge"`
 | |
| VGA=`sudo lspci -nn |grep "VGA\|Display" | sed -e "s/^/\t\t/"`
 | |
| HDD=`cat /proc/scsi/scsi |grep Model |cut -d ':' -f3- | sed -e "s/^[[:space:]]*/\t\t/"`
 | |
| RAM=`xl info |grep total_memory |cut -d ':' -f2 |tr -d ' '`
 | |
| BIOS=`sudo dmidecode |grep -A9 "BIOS Information" |grep "Version" |cut -d ' ' -f2-`
 | |
| XLINFO=`sudo xl info |grep "virt_caps"`
 | |
| XEN_MAJOR=`sudo xl info |grep xen_major |cut -d: -f2 |tr -d ' '`
 | |
| XEN_MINOR=`sudo xl info |grep xen_minor |cut -d: -f2 |tr -d ' '`
 | |
| XEN_EXTRA=`sudo xl info |grep xen_extra |cut -d: -f2 |tr -d ' '`
 | |
| 
 | |
| FILENAME="Qubes-HCL-$BRAND-$PRODUCT-$DATE"
 | |
| 
 | |
| if [[ "$XLINFO" =~ "hvm_directio" ]]
 | |
|  then 
 | |
|     VTX="Active"
 | |
|     HVM="good"
 | |
| 
 | |
|     VTD="Active"
 | |
|     IOMMU="good"
 | |
| 
 | |
|  elif [[ "$XLINFO" =~ "hvm" ]]
 | |
|  then
 | |
|     VTX="Active"
 | |
|     HVM="good"
 | |
| 
 | |
|     VTD="Not Active"
 | |
|     IOMMU="bad"
 | |
| 
 | |
|  else
 | |
|     VTX="Not Active"
 | |
|     HVM="bad"
 | |
| 
 | |
|     VTD="Not Active"
 | |
|     IOMMU="bad"
 | |
| fi
 | |
| 
 | |
| sudo cat /etc/qubes-release |tee ~/$FILENAME.txt
 | |
| echo
 | |
| echo -e "Model Name:\t$BRAND $PRODUCT" |tee -a ~/$FILENAME.txt
 | |
| echo -e "Kernel:\t\t$KERNEL" |tee -a ~/$FILENAME.txt
 | |
| echo -e "Xen:\t\t$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA\n" |tee -a ~/$FILENAME.txt
 | |
| echo -e "RAM:\t\t$RAM Mb\n" |tee -a  ~/$FILENAME.txt
 | |
| echo -e "CPU:\t\t$CPU" |tee -a  ~/$FILENAME.txt
 | |
| echo -e "Chipset:\t$CHIPSET" |tee -a ~/$FILENAME.txt
 | |
| echo -e "VGA:$VGA\n" |tee -a ~/$FILENAME.txt
 | |
| echo -e "HDD:$HDD\n" |tee -a ~/$FILENAME.txt
 | |
| echo -e "BIOS:\t\t$BIOS" |tee -a ~/$FILENAME.txt
 | |
| echo -e "VT-x:\t\t$VTX" |tee -a ~/$FILENAME.txt
 | |
| echo -e "VT-d:\t\t$VTD" |tee -a ~/$FILENAME.txt
 | |
| echo
 | |
| 
 | |
| echo -e "
 | |
| >-->-->-->-->--> HCL Wiki format begins >-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->
 | |
| 
 | |
| <!--
 | |
| Insert devices in alphabetical order.
 | |
| Change hcl-FIXME to appropriate class (see legend):
 | |
| hcl-good, hcl-bad, hcl-partial, hcl-unknown
 | |
| 
 | |
| Go to https://groups.google.com/forum/#!forum/qubes-users and search
 | |
| the message containing the HCL report.
 | |
| Then click on "more message options" besides reply button and then on
 | |
| link and insert it into FIXLINK.
 | |
| -->
 | |
| 
 | |
| <tr align='center'>
 | |
|  <td rowspan='1'>
 | |
|     $BRAND $PRODUCT<br>
 | |
|    (CPU, Chipset, embedded VGA)
 | |
|  </td>
 | |
|  <td rowspan='1'>${BIOS}</td>\t\t\t\t<!-- BIOS version\t\t# reported BIOS version -->
 | |
|  <td rowspan='1' class='hcl-${HVM}'></td>\t\t\t<!-- HVM\t\t\t# HVM can be created? -->
 | |
|  <td rowspan='1' class='hcl-${IOMMU}'></td>\t\t\t<!-- IOMMU\t\t\t# PCI-Devices can be assigned to a HVM? -->
 | |
|  <td rowspan='1' class='hcl-unknown'></td>\t\t<!-- TPM\t\t\t# Anti Evil Made works? -->
 | |
|  <td rowspan='1'></td>\t\t\t\t\t<!-- spacing (QSL)\t\t# best achievable QSL - (Qubes Security Level) -->
 | |
| 
 | |
|  <td rowspan='1' class='hcl-FIXME'>R2</td>\t\t<!-- Qubes version\t\t# first reported Qubes version -->
 | |
|  <td rowspan='1' class='hcl-FIXME'>${KERNEL}</td>\t<!-- dom0 kernel\t\t# Boots with this kernel version (refer to exact kernel version). -->
 | |
|  <td rowspan='1' class='hcl-FIXME'>\n     \n </td>\t\t\t\t\t\t\t<!-- Remarks -->
 | |
|  <td rowspan='1' class='hcl-reportedby'>
 | |
|     <a class='ext-link' href='FIXLINK'><span class='icon'></span>insert name</a>
 | |
|  </td>\t\t\t\t\t\t\t<!-- Reported by -->
 | |
| </tr>
 | |
| 
 | |
| 
 | |
| <!--
 | |
| If you add a report to an existing device increment the rowspan of
 | |
| first entry for Device, BIOS, HVM, IOMMU, TPM, spacing(QSL)
 | |
| and append the following with the new report data filled in:
 | |
| -->
 | |
| 
 | |
| <tr align='center'>
 | |
|  <td rowspan='1' class='hcl-FIXME'>R2</td>\t\t<!-- Qubes version\t\t# latest reported Qubes version -->
 | |
|  <td rowspan='1' class='hcl-FIXME'>${KERNEL}</td>\t<!-- dom0 kernel\t\t# Boots with this kernel version (refer to exact kernel version). -->
 | |
|  <td rowspan='1' class='hcl-FIXME'>\n     \n </td>\t\t\t\t\t\t\t<!-- Remarks -->
 | |
|  <td rowspan='1' class='hcl-reportedby'>
 | |
|     <a class='ext-link' href='FIXLINK'><span class='icon'></span>insert name</a>
 | |
|  </td>\t\t\t\t\t\t\t<!-- Reported by -->
 | |
| </tr>
 | |
| " >> ~/$FILENAME.txt
 | |
| 
 | |
| TEMP_DIR=`mktemp -d`
 | |
| sudo cat /etc/qubes-release > $TEMP_DIR/qubes-release
 | |
| sudo cat /proc/cpuinfo > $TEMP_DIR/cpuinfo
 | |
| sudo lspci -nnvk > $TEMP_DIR/lspci
 | |
| sudo dmidecode > $TEMP_DIR/dmidecode
 | |
| sudo xl info > $TEMP_DIR/xl
 | |
| 
 | |
| 
 | |
| # cpio
 | |
| cd $TEMP_DIR
 | |
| find -print0 |cpio --quiet -o -H crc --null |gzip  >~/$FILENAME.cpio.gz
 | |
| cd
 | |
| 
 | |
| 
 | |
| # VM check
 | |
| if [[ "$COPY2VM" != "dom0" ]]
 | |
|  then
 | |
|     # Copy to VM
 | |
|     qvm-start -q $COPY2VM 2>/dev/null
 | |
|     cat ~/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz"
 | |
|     cat ~/$FILENAME.txt | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.txt"
 | |
| fi
 | |
| 
 | |
| echo -e "Qubes HCL Support files are copied to: '$COPY2VM'"
 | |
| echo -e "\t$FILENAME.txt\t\t- HCL Info"
 | |
| echo -e "\t$FILENAME.cpio.gz\t- HCL Support Files"
 | |
| 
 | |
| 
 | |
| # cleanup
 | |
| if [[ -d $TEMP_DIR ]]
 | |
|  then
 | |
|     rm -rf $TEMP_DIR
 | |
| fi
 | |
| 
 | 
