mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
New version, new tarball. Extended support and tests for vm id to include better BSD
handling, and legacy linux. VM id will remain a work in progress, and will probably require a few fixes for fringe cases. Nice to have would be things like OpenBSD's vm which is difficult to detect. However, I believe this should handle roughly 99% of realworld vm id cases, except for some commercial stuff that will require more data.
This commit is contained in:
parent
344af561f1
commit
1f5a06471e
34
inxi
34
inxi
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### Version: 2.3.2
|
||||
#### Date: 2016-10-23
|
||||
#### Version: 2.3.3
|
||||
#### Date: 2016-10-25
|
||||
#### Patch Number: 00
|
||||
########################################################################
|
||||
#### SPECIAL THANKS
|
||||
|
@ -5457,12 +5457,15 @@ get_device_vm()
|
|||
local vm='other-vm?' vm_data='' vm_test=''
|
||||
|
||||
# https://www.freedesktop.org/software/systemd/man/systemd-detect-virt.html
|
||||
# note: unknown is how reliable this tool is
|
||||
if type -p systemd-detect-virt &>/dev/null;then
|
||||
vm_test=$(systemd-detect-virt 2>/dev/null)
|
||||
vm_test=$(systemd-detect-virt 2>/dev/null | sed 's/none//' )
|
||||
if [[ -n $vm_test && $vm_test != 'none' ]];then
|
||||
vm=$vm_test
|
||||
fi
|
||||
else
|
||||
fi
|
||||
# some simple to detect linux vm id's
|
||||
if [[ $vm == 'other-vm?' ]];then
|
||||
if [[ -e /proc/vz ]];then
|
||||
vm='openvz'
|
||||
elif [[ -e /proc/xen ]];then
|
||||
|
@ -5470,6 +5473,8 @@ get_device_vm()
|
|||
elif [[ -e /dev/vzfs ]];then
|
||||
vm='virtuozzo'
|
||||
fi
|
||||
fi
|
||||
# this will catch many Linux systems and some BSDs
|
||||
if [[ $vm == 'other-vm?' ]];then
|
||||
vm_data=$vm_data$Lspci_v_Data
|
||||
vm_data=$vm_data$Sysctl_a_Data
|
||||
|
@ -5483,12 +5488,33 @@ get_device_vm()
|
|||
vm='vmware'
|
||||
elif [[ -n $( grep -is 'qemu' <<< $vm_data ) ]];then
|
||||
vm='qemu-or-kvm'
|
||||
elif [[ -n $( grep -s 'Virtual HD' <<< $vm_data ) ]];then
|
||||
vm='hyper-v'
|
||||
elif [[ -e /proc/cpuinfo && -n $( grep -is '^flags.*hypervisor' /proc/cpuinfo ) ]];then
|
||||
vm='virtual-machine'
|
||||
elif [[ -e /dev/vda || -e /dev/vdb || -e /dev/xvda || -e /dev/xvdb ]];then
|
||||
vm='virtual-machine'
|
||||
fi
|
||||
fi
|
||||
# this may catch some BSD and fringe Linux cases
|
||||
if [[ $vm == 'other-vm?' && $B_ROOT == 'true' ]];then
|
||||
if [[ -n $DMIDECODE_DATA && $DMIDECODE_DATA != 'dmidecode-error-'* ]];then
|
||||
product_name=$(dmidecode -s system-product-name 2>/dev/null )
|
||||
system_manufacturer=$( dmidecode -s system-manufacturer 2>/dev/null )
|
||||
if [[ $product_name == 'VMware'* ]];then
|
||||
vm='vmware'
|
||||
elif [[ $product_name == 'VirtualBox'* ]];then
|
||||
vm='virtualbox'
|
||||
elif [[ $product_name == 'KVM'* ]];then
|
||||
vm='kvm'
|
||||
elif [[ $product_name == 'Bochs'* ]];then
|
||||
vm='qemu'
|
||||
elif [[ $system_manufacturer == 'Xen' ]];then
|
||||
vm='xen'
|
||||
elif [[ -n $( grep -i 'hypervisor' <<< "$DMIDECODE_DATA" ) ]];then
|
||||
vm='virtual-machine'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $vm
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
=====================================================================================
|
||||
Version: 2.3.3
|
||||
Patch Version: 00
|
||||
Script Date: 2016-10-25
|
||||
-----------------------------------
|
||||
Changes:
|
||||
-----------------------------------
|
||||
New version, new tarball. Extended support and tests for vm id to include better BSD
|
||||
handling, and legacy linux. VM id will remain a work in progress, and will probably
|
||||
require a few fixes for fringe cases. Nice to have would be things like OpenBSD's
|
||||
vm which is difficult to detect. However, I believe this should handle roughly 99% of
|
||||
realworld vm id cases, except for some commercial stuff that will require more data.
|
||||
|
||||
-----------------------------------
|
||||
-- Harald Hope - Tue, 25 Oct 2016 12:17:46 -0700
|
||||
|
||||
=====================================================================================
|
||||
Version: 2.3.2
|
||||
Patch Version: 00
|
||||
|
|
Loading…
Reference in a new issue