2013-02-28 14:27:56 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-06-23 20:13:03 +02:00
|
|
|
# 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.
|
|
|
|
|
2016-02-25 15:05:06 +01:00
|
|
|
VERSION=2.5
|
2014-11-18 14:28:11 +01:00
|
|
|
COPY2VM="dom0"
|
|
|
|
SUPPORT_FILES=0
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
|
|
|
|
-s |--support)
|
|
|
|
SUPPORT_FILES=1
|
|
|
|
;;
|
|
|
|
|
|
|
|
-* | -h | --help)
|
|
|
|
echo -e "qubes-hcl-report v$VERSION"
|
|
|
|
echo ""
|
|
|
|
echo "This tool is used to gather basic hardware information for the Qubes HCL (Hardware Compatibility List)"
|
|
|
|
echo "and copy the results to the given AppVM for the easy contribution."
|
|
|
|
echo ""
|
|
|
|
echo -e "Usage:\tqubes-hcl-report [OPTIONS] [<AppVM Name>]"
|
|
|
|
echo -e "Options are:"
|
|
|
|
echo -e "\t-h, --help\tDisplay this help text and exit."
|
|
|
|
echo -e "\t-s, --support\tGenerate more detailed HCL Support Files"
|
|
|
|
echo -e "\t\t\tWARNING: The HCL Support Files may contain numerous hardware details, including serial numbers."
|
|
|
|
echo -e "\t\t\tIf, for privacy or security reasons, you do not wish to make this information public, "
|
|
|
|
echo -e "\t\t\tplease do not send the .cpio.gz file to the public mailing list."
|
|
|
|
echo ""
|
|
|
|
echo -e "\t<AppVM Name>\tCopy the results to the given AppVM. The default is to keep it in dom0"
|
|
|
|
echo ""
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
/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
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2014-03-25 10:34:25 +01:00
|
|
|
DATE=`date +%Y%m%d-%H%M%S`
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2014-11-18 14:28:11 +01:00
|
|
|
|
|
|
|
TEMP_DIR=`mktemp --tmpdir -d HCL.XXXXXXXXXX`
|
|
|
|
cat /etc/qubes-release > $TEMP_DIR/qubes-release
|
|
|
|
cat /proc/cpuinfo > $TEMP_DIR/cpuinfo
|
|
|
|
lspci -nnvk > $TEMP_DIR/lspci
|
|
|
|
cat /proc/scsi/scsi > $TEMP_DIR/scsi
|
|
|
|
sudo dmidecode > $TEMP_DIR/dmidecode
|
|
|
|
xl info > $TEMP_DIR/xl-info
|
|
|
|
xl dmesg > $TEMP_DIR/xl-dmesg
|
|
|
|
|
|
|
|
|
2015-05-04 15:47:50 +02:00
|
|
|
BRAND=`cat $TEMP_DIR/dmidecode |grep -A9 "System Information" |grep "Manufacturer:" |cut -d ' ' -f2-`
|
|
|
|
PRODUCT=`cat $TEMP_DIR/dmidecode |grep -A9 "System Information" |grep "Product Name:" |cut -d ' ' -f3-`
|
2015-06-02 12:16:45 +02:00
|
|
|
TYPE=`cat $TEMP_DIR/dmidecode |grep -A9 "Chassis Information" |grep Type |cut -d ' ' -f2- |tr '[:upper:]' '[:lower:]'`
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2013-06-23 20:13:03 +02:00
|
|
|
if [[ $BRAND =~ "O.E.M" ]]
|
|
|
|
then
|
2015-05-04 15:47:50 +02:00
|
|
|
BRAND=`cat $TEMP_DIR/dmidecode |grep -A9 "Base Board Information" |grep "Manufacturer:" |cut -d ' ' -f2-`
|
|
|
|
PRODUCT=`cat $TEMP_DIR/dmidecode |grep -A9 "Base Board Information" |grep "Product Name:" |cut -d ' ' -f3-`
|
2013-06-23 20:13:03 +02:00
|
|
|
fi
|
|
|
|
|
2014-05-09 16:39:12 +02:00
|
|
|
KERNEL=`uname -r |cut -d '.' -f-3`
|
2015-05-04 15:47:50 +02:00
|
|
|
CPU=`cat $TEMP_DIR/cpuinfo |grep "model name" |sort -u |cut -d ' ' -f3- |sed -e "s/[[:space:]]*/\ /"`
|
|
|
|
CHIPSET=`cat $TEMP_DIR/lspci |grep "00:00.0.*Host bridge" |cut -d ':' -f3- |sed -e "s/[[:space:]]*/\ /"`
|
|
|
|
VGA=`cat $TEMP_DIR/lspci |grep "VGA\|Display" |cut -d ':' -f3- |sed -e "s/^[[:space:]]*/\ /"`
|
|
|
|
NET=`cat $TEMP_DIR/lspci |lspci |grep "Network\|Ethernet" |cut -d ':' -f3- |sed -e "s/^[[:space:]]*/\ /"`
|
|
|
|
SCSI=`cat $TEMP_DIR/scsi |grep Model |cut -d ':' -f3-|sed -e "s/^[[:space:]]*/\ /"`
|
2014-11-18 14:28:11 +01:00
|
|
|
RAM=`cat $TEMP_DIR/xl-info |grep total_memory |cut -d ':' -f2 |tr -d ' '`
|
|
|
|
BIOS=`cat $TEMP_DIR/dmidecode |grep -A9 "BIOS Information" |grep "Version" |cut -d ' ' -f2-`
|
|
|
|
XEN_MAJOR=`cat $TEMP_DIR/xl-info |grep xen_major |cut -d: -f2 |tr -d ' '`
|
|
|
|
XEN_MINOR=`cat $TEMP_DIR/xl-info |grep xen_minor |cut -d: -f2 |tr -d ' '`
|
|
|
|
XEN_EXTRA=`cat $TEMP_DIR/xl-info |grep xen_extra |cut -d: -f2 |tr -d ' '`
|
2015-05-04 15:47:50 +02:00
|
|
|
QUBES=`cat $TEMP_DIR/qubes-release |cut -d '(' -f2 |cut -d ')' -f1`
|
2014-11-18 14:28:11 +01:00
|
|
|
XL_VTX=`cat $TEMP_DIR/xl-info |grep xen_caps | grep hvm`
|
|
|
|
XL_VTD=`cat $TEMP_DIR/xl-info |grep virt_caps |grep hvm_directio`
|
2015-05-04 15:47:50 +02:00
|
|
|
PCRS=`find /sys/devices/ -name pcrs`
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2016-05-18 14:21:26 +02:00
|
|
|
FILENAME="Qubes-HCL-${BRAND//[^[:alnum:]]/_}-${PRODUCT//[^[:alnum:]]/_}-$DATE"
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2014-11-18 14:28:11 +01:00
|
|
|
if [[ $XL_VTX ]]
|
|
|
|
then
|
2013-06-23 20:13:03 +02:00
|
|
|
VTX="Active"
|
2015-05-04 15:47:50 +02:00
|
|
|
HVM="yes"
|
2014-05-09 16:39:12 +02:00
|
|
|
|
2013-02-28 14:27:56 +01:00
|
|
|
else
|
2015-05-04 15:47:50 +02:00
|
|
|
VTX="Not active"
|
|
|
|
HVM="no"
|
2014-05-09 16:39:12 +02:00
|
|
|
|
2014-11-18 14:28:11 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $XL_VTD ]]
|
|
|
|
then
|
|
|
|
VTD="Active"
|
2015-05-04 15:47:50 +02:00
|
|
|
IOMMU="yes"
|
2014-11-18 14:28:11 +01:00
|
|
|
|
|
|
|
else
|
2015-05-04 15:47:50 +02:00
|
|
|
VTD="Not active"
|
|
|
|
IOMMU="no"
|
2014-11-18 14:28:11 +01:00
|
|
|
|
2013-02-28 14:27:56 +01:00
|
|
|
fi
|
|
|
|
|
2015-05-04 15:47:50 +02:00
|
|
|
if [[ $PCRS ]]
|
|
|
|
then
|
|
|
|
# try tu run tcsd and: grep the logs, try get version info.
|
|
|
|
TPM="Device present"
|
|
|
|
else
|
|
|
|
TPM="Device not found"
|
|
|
|
TPM_s="unknown"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
cat /etc/qubes-release
|
2013-02-28 14:27:56 +01:00
|
|
|
echo
|
2015-05-04 15:47:50 +02:00
|
|
|
echo -e "Brand:\t\t$BRAND"
|
|
|
|
echo -e "Model:\t\t$PRODUCT"
|
|
|
|
echo -e "BIOS:\t\t$BIOS\n"
|
|
|
|
echo -e "Xen:\t\t$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA"
|
|
|
|
echo -e "Kernel:\t\t$KERNEL\n"
|
|
|
|
echo -e "RAM:\t\t$RAM Mb\n"
|
|
|
|
echo -e "CPU:\n$CPU"
|
|
|
|
echo -e "Chipset:\n$CHIPSET"
|
|
|
|
echo -e "VGA:\n${VGA}\n"
|
|
|
|
echo -e "Net:\n$NET\n"
|
|
|
|
echo -e "SCSI:\n$SCSI\n"
|
|
|
|
echo -e "HVM:\t\t$VTX"
|
|
|
|
echo -e "I/O MMU:\t$VTD"
|
|
|
|
echo -e "TPM:\t\t$TPM"
|
2013-02-28 14:27:56 +01:00
|
|
|
echo
|
|
|
|
|
2015-06-02 12:16:45 +02:00
|
|
|
echo -e "---
|
2015-06-02 09:19:54 +02:00
|
|
|
layout:
|
|
|
|
'hcl'
|
|
|
|
type:
|
|
|
|
'$TYPE'
|
|
|
|
hvm:
|
|
|
|
'$HVM'
|
|
|
|
iommu:
|
|
|
|
'$IOMMU'
|
|
|
|
tpm:
|
|
|
|
'$TPM_s'
|
|
|
|
brand: |
|
|
|
|
$BRAND
|
|
|
|
model: |
|
|
|
|
$PRODUCT
|
|
|
|
bios: |
|
|
|
|
$BIOS
|
|
|
|
cpu: |
|
2015-05-04 15:47:50 +02:00
|
|
|
$CPU
|
2015-06-02 09:19:54 +02:00
|
|
|
cpu-short: |
|
|
|
|
FIXME
|
|
|
|
chipset: |
|
2015-05-04 15:47:50 +02:00
|
|
|
$CHIPSET
|
2015-06-02 09:19:54 +02:00
|
|
|
chipset-short: |
|
|
|
|
FIXME
|
|
|
|
gpu: |
|
2015-05-04 15:47:50 +02:00
|
|
|
$VGA
|
2015-06-02 09:19:54 +02:00
|
|
|
gpu-short: |
|
|
|
|
FIXME
|
|
|
|
network: |
|
2015-05-04 15:47:50 +02:00
|
|
|
$NET
|
2015-06-02 09:19:54 +02:00
|
|
|
memory: |
|
|
|
|
$RAM
|
|
|
|
scsi: |
|
2015-05-04 15:47:50 +02:00
|
|
|
$SCSI
|
|
|
|
|
|
|
|
versions:
|
|
|
|
|
2015-06-02 09:19:54 +02:00
|
|
|
- works:
|
|
|
|
'FIXME:yes|no|partial'
|
|
|
|
qubes: |
|
|
|
|
$QUBES
|
|
|
|
xen: |
|
|
|
|
$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA
|
|
|
|
kernel: |
|
|
|
|
$KERNEL
|
|
|
|
remark: |
|
2015-05-04 15:47:50 +02:00
|
|
|
FIXME
|
2015-06-02 09:19:54 +02:00
|
|
|
credit: |
|
|
|
|
FIXAUTHOR
|
|
|
|
link: |
|
|
|
|
FIXLINK
|
|
|
|
|
2015-05-04 15:47:50 +02:00
|
|
|
---
|
2016-06-28 00:10:00 +02:00
|
|
|
" >> "$HOME/$FILENAME.yml"
|
2013-02-28 14:27:56 +01:00
|
|
|
|
|
|
|
|
2014-11-18 14:28:11 +01:00
|
|
|
if [[ "$SUPPORT_FILES" == 1 ]]
|
|
|
|
then
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2014-11-18 14:28:11 +01:00
|
|
|
# cpio
|
|
|
|
cd $TEMP_DIR
|
|
|
|
find -print0 |cpio --quiet -o -H crc --null |gzip >$HOME/$FILENAME.cpio.gz
|
|
|
|
cd
|
|
|
|
fi
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2014-11-18 14:28:11 +01:00
|
|
|
# Destination VM check
|
2013-06-23 20:13:03 +02:00
|
|
|
if [[ "$COPY2VM" != "dom0" ]]
|
|
|
|
then
|
|
|
|
# Copy to VM
|
|
|
|
qvm-start -q $COPY2VM 2>/dev/null
|
2014-11-18 14:28:11 +01:00
|
|
|
|
|
|
|
if [[ -f "$HOME/$FILENAME.cpio.gz" ]]
|
|
|
|
then
|
|
|
|
cat $HOME/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz"
|
|
|
|
fi
|
|
|
|
|
2015-05-04 15:47:50 +02:00
|
|
|
if [[ -f "$HOME/$FILENAME.yml" ]]
|
2014-11-18 14:28:11 +01:00
|
|
|
then
|
2015-05-04 15:47:50 +02:00
|
|
|
cat $HOME/$FILENAME.yml | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.yml"
|
2014-11-18 14:28:11 +01:00
|
|
|
fi
|
|
|
|
|
2013-06-23 20:13:03 +02:00
|
|
|
fi
|
|
|
|
|
2014-11-18 14:28:11 +01:00
|
|
|
echo -e "Qubes HCL Files are copied to: '$COPY2VM'"
|
2015-05-04 15:47:50 +02:00
|
|
|
echo -e "\t$FILENAME.yml\t\t- HCL Info"
|
2014-11-18 14:28:11 +01:00
|
|
|
|
|
|
|
if [[ "$SUPPORT_FILES" == 1 ]]
|
|
|
|
then
|
|
|
|
echo -e "\t$FILENAME.cpio.gz\t- HCL Support Files"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2013-02-28 14:27:56 +01:00
|
|
|
|
2013-06-23 20:13:03 +02:00
|
|
|
|
2013-02-28 14:27:56 +01:00
|
|
|
# cleanup
|
|
|
|
if [[ -d $TEMP_DIR ]]
|
|
|
|
then
|
2014-11-18 14:28:11 +01:00
|
|
|
rm -rf $TEMP_DIR
|
2013-02-28 14:27:56 +01:00
|
|
|
fi
|
|
|
|
|