Wiki -> YML output format change + basic TPM detection

(cherry picked from commit 28097bfdf1e3220a9de295cb7621d611d4f0620b)
This commit is contained in:
Zrubi 2015-05-04 15:47:50 +02:00 committed by Marek Marczykowski-Górecki
parent 47a6bf4f7a
commit 770cf5cce0

View File

@ -18,7 +18,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
VERSION=2.2 VERSION=2.3
COPY2VM="dom0" COPY2VM="dom0"
SUPPORT_FILES=0 SUPPORT_FILES=0
@ -77,120 +77,123 @@ xl info > $TEMP_DIR/xl-info
xl dmesg > $TEMP_DIR/xl-dmesg xl dmesg > $TEMP_DIR/xl-dmesg
BRAND=`cat $TEMP_DIR/dmidecode |grep -A9 "System Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _` 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- |tr -s '[:blank:]' _` PRODUCT=`cat $TEMP_DIR/dmidecode |grep -A9 "System Information" |grep "Product Name:" |cut -d ' ' -f3-`
TYPE=`cat $TEMP_DIR/dmidecode |grep -A9 "Chassis Information" |grep Type |cut -d ' ' -f2-`
if [[ $BRAND =~ "O.E.M" ]] if [[ $BRAND =~ "O.E.M" ]]
then then
BRAND=`cat $TEMP_DIR/dmidecode |grep -A9 "Base Board Information" |grep "Manufacturer:" |cut -d ' ' -f2- |tr -s '[:blank:]' _` 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- |tr -s '[:blank:]' _` PRODUCT=`cat $TEMP_DIR/dmidecode |grep -A9 "Base Board Information" |grep "Product Name:" |cut -d ' ' -f3-`
fi fi
KERNEL=`uname -r |cut -d '.' -f-3` KERNEL=`uname -r |cut -d '.' -f-3`
CPU=`cat $TEMP_DIR/cpuinfo |grep "model name" |sort -u |cut -d ' ' -f3-` 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"` 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" | sed -e "s/^/\t\t/"` VGA=`cat $TEMP_DIR/lspci |grep "VGA\|Display" |cut -d ':' -f3- |sed -e "s/^[[:space:]]*/\ /"`
NET=`cat $TEMP_DIR/lspci |lspci |grep "Network\|Ethernet" |sed -e "s/^/\t\t/"` 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:]]*/\t\t/"` SCSI=`cat $TEMP_DIR/scsi |grep Model |cut -d ':' -f3-|sed -e "s/^[[:space:]]*/\ /"`
RAM=`cat $TEMP_DIR/xl-info |grep total_memory |cut -d ':' -f2 |tr -d ' '` 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-` 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_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_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 ' '` XEN_EXTRA=`cat $TEMP_DIR/xl-info |grep xen_extra |cut -d: -f2 |tr -d ' '`
QUBES=`cat $TEMP_DIR/qubes-release |cut -d '(' -f2 |cut -d ')' -f1`
XL_VTX=`cat $TEMP_DIR/xl-info |grep xen_caps | grep hvm` 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` XL_VTD=`cat $TEMP_DIR/xl-info |grep virt_caps |grep hvm_directio`
PCRS=`find /sys/devices/ -name pcrs`
FILENAME="Qubes-HCL-${BRAND// /_}-${PRODUCT// /_}-$DATE"
FILENAME="Qubes-HCL-$BRAND-$PRODUCT-$DATE"
if [[ $XL_VTX ]] if [[ $XL_VTX ]]
then then
VTX="Active" VTX="Active"
HVM="good" HVM="yes"
else else
VTX="Not Active" VTX="Not active"
HVM="bad" HVM="no"
fi fi
if [[ $XL_VTD ]] if [[ $XL_VTD ]]
then then
VTD="Active" VTD="Active"
IOMMU="good" IOMMU="yes"
else else
VTD="Not Active" VTD="Not active"
IOMMU="bad" IOMMU="no"
fi fi
cat /etc/qubes-release |tee $HOME/$FILENAME.txt 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
echo echo
echo -e "Model Name:\t$BRAND $PRODUCT" |tee -a $HOME/$FILENAME.txt echo -e "Brand:\t\t$BRAND"
echo -e "Kernel:\t\t$KERNEL" |tee -a $HOME/$FILENAME.txt echo -e "Model:\t\t$PRODUCT"
echo -e "Xen:\t\t$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA\n" |tee -a $HOME/$FILENAME.txt echo -e "BIOS:\t\t$BIOS\n"
echo -e "RAM:\t\t$RAM Mb\n" |tee -a $HOME/$FILENAME.txt echo -e "Xen:\t\t$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA"
echo -e "CPU:\t\t$CPU" |tee -a $HOME/$FILENAME.txt echo -e "Kernel:\t\t$KERNEL\n"
echo -e "Chipset:\t$CHIPSET" |tee -a $HOME/$FILENAME.txt echo -e "RAM:\t\t$RAM Mb\n"
echo -e "VGA:$VGA\n" |tee -a $HOME/$FILENAME.txt echo -e "CPU:\n$CPU"
echo -e "Net:$NET\n" |tee -a $HOME/$FILENAME.txt echo -e "Chipset:\n$CHIPSET"
echo -e "SCSI:$SCSI\n" |tee -a $HOME/$FILENAME.txt echo -e "VGA:\n${VGA}\n"
echo -e "BIOS:\t\t$BIOS" |tee -a $HOME/$FILENAME.txt echo -e "Net:\n$NET\n"
echo -e "VT-x:\t\t$VTX" |tee -a $HOME/$FILENAME.txt echo -e "SCSI:\n$SCSI\n"
echo -e "VT-d:\t\t$VTD" |tee -a $HOME/$FILENAME.txt echo -e "HVM:\t\t$VTX"
echo -e "I/O MMU:\t$VTD"
echo -e "TPM:\t\t$TPM"
echo echo
echo -e " echo -e "
>-->-->-->-->--> HCL Wiki format begins >-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->--> ---
layout: 'hcl'
brand: '$BRAND'
model: '$PRODUCT'
type: '$TYPE'
bios: '$BIOS'
ram: '$RAM'
hvm: '$HVM'
iommu: '$IOMMU'
tpm: '$TPM_s'
cpu-short: 'FIXME'
cpu: |
$CPU
chipset-sort: 'FIXME'
chipset: |
$CHIPSET
gpu-short: 'FIXME'
gpu: |
$VGA
network: |
$NET
scsi: |
$SCSI
<!-- versions:
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 - qubes: '$QUBES'
the message containing the HCL report. xen: '$XEN_MAJOR.$XEN_MINOR$XEN_EXTRA'
Then click on "more message options" besides reply button and then on kernel: '$KERNEL'
link and insert it into FIXLINK. works: 'FIXME'
-->
<tr align='center'> remark: |
<td rowspan='1'> FIXME
$BRAND $PRODUCT<br> credit: |
(CPU, Chipset, embedded VGA) FIXME
</td> ---
<td rowspan='1'>${BIOS}</td>\t\t\t\t<!-- BIOS version\t\t# reported BIOS version --> # vim: ts=2 sw=2 et nowrap
<td rowspan='1' class='hcl-${HVM}'></td>\t\t\t<!-- HVM\t\t\t# HVM can be created? --> " >> $HOME/$FILENAME.yml
<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>
" >> $HOME/$FILENAME.txt
if [[ "$SUPPORT_FILES" == 1 ]] if [[ "$SUPPORT_FILES" == 1 ]]
@ -213,15 +216,15 @@ if [[ "$COPY2VM" != "dom0" ]]
cat $HOME/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz" cat $HOME/$FILENAME.cpio.gz | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.cpio.gz"
fi fi
if [[ -f "$HOME/$FILENAME.txt" ]] if [[ -f "$HOME/$FILENAME.yml" ]]
then then
cat $HOME/$FILENAME.txt | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.txt" cat $HOME/$FILENAME.yml | qvm-run -a -q --pass-io $COPY2VM "cat >/home/user/$FILENAME.yml"
fi fi
fi fi
echo -e "Qubes HCL Files are copied to: '$COPY2VM'" echo -e "Qubes HCL Files are copied to: '$COPY2VM'"
echo -e "\t$FILENAME.txt\t\t- HCL Info" echo -e "\t$FILENAME.yml\t\t- HCL Info"
if [[ "$SUPPORT_FILES" == 1 ]] if [[ "$SUPPORT_FILES" == 1 ]]
then then