add machine detection support for windows

This commit is contained in:
abbie 2024-11-12 19:20:36 +00:00
parent 93d8341bad
commit 25083ef411
Signed by: threeoh6000
GPG key ID: 801FE4AD456E922C

View file

@ -1,4 +1,4 @@
if [ -f /etc/lsb-release ] && [ $system_type = "linux" ]; then if [ -f /etc/lsb-release ] && [ "$system_type" = "linux" ]; then
if [ "$hasawk" -eq 1 ] && [ -z "$distro" ]; then if [ "$hasawk" -eq 1 ] && [ -z "$distro" ]; then
if [ -n "$(cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | awk -F "\"" '{print $2}') $(cat /etc/lsb-release | grep DISTRIB_RELEASE | awk -F "\"" '{print $2}')" ] && [ "$(cat /etc/lsb-release | grep DISTRIB_RELEASE | awk -F "\"" '{print $2}')" != "rolling" ]; then if [ -n "$(cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | awk -F "\"" '{print $2}') $(cat /etc/lsb-release | grep DISTRIB_RELEASE | awk -F "\"" '{print $2}')" ] && [ "$(cat /etc/lsb-release | grep DISTRIB_RELEASE | awk -F "\"" '{print $2}')" != "rolling" ]; then
distro="$(cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | awk -F "\"" '{print $2}') $(cat /etc/lsb-release | grep DISTRIB_RELEASE | awk -F "\"" '{print $2}')" distro="$(cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | awk -F "\"" '{print $2}') $(cat /etc/lsb-release | grep DISTRIB_RELEASE | awk -F "\"" '{print $2}')"
@ -7,7 +7,7 @@ if [ -f /etc/lsb-release ] && [ $system_type = "linux" ]; then
fi fi
fi fi
fi fi
if [ -f /etc/os-release ] && [ $system_type = "linux" ]; then if [ -f /etc/os-release ] && [ "$system_type" = "linux" ]; then
if [ "$hasawk" -eq 1 ] && [ -z "$distro" ]; then if [ "$hasawk" -eq 1 ] && [ -z "$distro" ]; then
if [ -n "$(cat /etc/os-release | grep PRETTY_NAME | awk -F "\"" '{print $2}')" ]; then if [ -n "$(cat /etc/os-release | grep PRETTY_NAME | awk -F "\"" '{print $2}')" ]; then
distro="$(cat /etc/os-release | grep PRETTY_NAME | awk -F "\"" '{print $2}')" distro="$(cat /etc/os-release | grep PRETTY_NAME | awk -F "\"" '{print $2}')"
@ -16,7 +16,7 @@ if [ -f /etc/os-release ] && [ $system_type = "linux" ]; then
fi fi
fi fi
fi fi
if [ $subtype = "chumby" ]; then if [ "$subtype" = "chumby" ]; then
distro="Chumby firmware $(chumby_version -s)" distro="Chumby firmware $(chumby_version -s)"
if [ "$hasawk" -eq 1 ]; then if [ "$hasawk" -eq 1 ]; then
if [ "$(chumby_version -h | awk -F "." '{print $1}')" = "3" ]; then if [ "$(chumby_version -h | awk -F "." '{print $1}')" = "3" ]; then
@ -30,36 +30,36 @@ if [ $subtype = "chumby" ]; then
fi fi
fi fi
fi fi
if [ $subtype = "proxmox" ]; then if [ "$subtype" = "proxmox" ]; then
if [ "$hasawk" -eq 1 ]; then if [ "$hasawk" -eq 1 ]; then
if [ -n "$(pveversion | awk -F "/" '{ print $2 }')" ]; then if [ -n "$(pveversion | awk -F "/" '{ print $2 }')" ]; then
distro="Proxmox VE $(pveversion | awk -F "/" '{ print $2 }')" distro="Proxmox VE $(pveversion | awk -F "/" '{ print $2 }')"
fi fi
fi fi
fi fi
if [ $system_type = "openbsd" ]; then if [ "$system_type" = "openbsd" ]; then
if [ "$hasawk" -eq 1 ]; then if [ "$hasawk" -eq 1 ]; then
distro="revision $(sysctl kern.osrevision | awk -F "=" '{print $2}')" distro="revision $(sysctl kern.osrevision | awk -F "=" '{print $2}')"
machine="$(sysctl hw.vendor | awk -F "=" '{print $2}') $(sysctl hw.product | awk -F "=" '{print $2}')" machine="$(sysctl hw.vendor | awk -F "=" '{print $2}') $(sysctl hw.product | awk -F "=" '{print $2}')"
fi fi
fi fi
if [ $system_type = "freebsd" ]; then if [ "$system_type" = "freebsd" ]; then
if [ "$hasawk" -eq 1 ]; then if [ "$hasawk" -eq 1 ]; then
distro="revision $(sysctl kern.osrevision | awk -F ": " '{print $2}')" distro="revision $(sysctl kern.osrevision | awk -F ": " '{print $2}')"
fi fi
machine="$(kenv smbios.system.maker) $(kenv smbios.system.product)" machine="$(kenv smbios.system.maker) $(kenv smbios.system.product)"
fi fi
if [ $system_type = "netbsd" ]; then if [ "$system_type" = "netbsd" ]; then
if [ "$hasawk" -eq 1 ]; then if [ "$hasawk" -eq 1 ]; then
distro="revision $(sysctl kern.osrevision | awk -F " = " '{print $2}')" distro="revision $(sysctl kern.osrevision | awk -F " = " '{print $2}')"
machine="$(sysctl machdep.dmi.system-vendor | awk -F " = " '{print $2}') $(sysctl machdep.dmi.system-product | awk -F " = " '{print $2}')" machine="$(sysctl machdep.dmi.system-vendor | awk -F " = " '{print $2}') $(sysctl machdep.dmi.system-product | awk -F " = " '{print $2}')"
fi fi
fi fi
if [ $system_type = "haiku" ]; then if [ "$system_type" = "haiku" ]; then
distro="$(uname -v)" distro="$(uname -v)"
fi fi
if [ $system_type = "linux" ] && [ -z "$machine" ]; then if [ "$system_type" = "linux" ] && [ -z "$machine" ]; then
if [ -f "/sys/devices/virtual/dmi/id/product_name" ]; then if [ -f "/sys/devices/virtual/dmi/id/product_name" ]; then
machine="$(cat /sys/devices/virtual/dmi/id/product_name)" machine="$(cat /sys/devices/virtual/dmi/id/product_name)"
fi fi
@ -67,3 +67,7 @@ if [ $system_type = "linux" ] && [ -z "$machine" ]; then
machine="$(cat /sys/devices/virtual/dmi/id/sys_vendor) $machine" machine="$(cat /sys/devices/virtual/dmi/id/sys_vendor) $machine"
fi fi
fi fi
if [ "$system_type" = "windows" ] && [ -z "$machine"]; && [ "$hassed" -eq 1 ]; then
machine="$(wmic.exe computersystem get Manufacturer,Model | sed -n 2p | head -n 1)"
fi