mirror of
https://github.com/bin456789/reinstall.git
synced 2025-09-22 16:16:02 +00:00
添加 windows 下检测是否是虚拟机的方法
This commit is contained in:
10
reinstall.sh
10
reinstall.sh
@@ -91,6 +91,12 @@ add_community_repo_for_alpine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_virt() {
|
is_virt() {
|
||||||
|
if is_in_windows; then
|
||||||
|
vmstr='VMware|Virtual|BOCHS|QEMU'
|
||||||
|
wmic ComputerSystem | grep -Eiw $vmstr && return 0
|
||||||
|
wmic bios | grep -Eiw $vmstr && return 0
|
||||||
|
wmic /namespace:'\\root\cimv2' PATH Win32_Fan | head -1 | grep -q -v Name
|
||||||
|
else
|
||||||
if command -v systemd-detect-virt; then
|
if command -v systemd-detect-virt; then
|
||||||
systemd-detect-virt
|
systemd-detect-virt
|
||||||
else
|
else
|
||||||
@@ -100,6 +106,7 @@ is_virt() {
|
|||||||
fi
|
fi
|
||||||
virt-what
|
virt-what
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
setos() {
|
setos() {
|
||||||
@@ -110,8 +117,7 @@ setos() {
|
|||||||
|
|
||||||
setos_alpine() {
|
setos_alpine() {
|
||||||
flavour=lts
|
flavour=lts
|
||||||
# 在windows中没有命令判断是否为虚拟机
|
if is_virt; then
|
||||||
if ! is_in_windows && is_virt; then
|
|
||||||
# alpine aarch64 3.18 才有 virt 直连链接
|
# alpine aarch64 3.18 才有 virt 直连链接
|
||||||
if [ "$basearch" == aarch64 ]; then
|
if [ "$basearch" == aarch64 ]; then
|
||||||
(($("$releasever >= 3.18" | bc))) && flavour=virt
|
(($("$releasever >= 3.18" | bc))) && flavour=virt
|
||||||
|
Reference in New Issue
Block a user