添加 windows 下检测是否是虚拟机的方法
This commit is contained in:
parent
6164b0c301
commit
09b3111d2b
22
reinstall.sh
22
reinstall.sh
@ -91,14 +91,21 @@ add_community_repo_for_alpine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_virt() {
|
is_virt() {
|
||||||
if command -v systemd-detect-virt; then
|
if is_in_windows; then
|
||||||
systemd-detect-virt
|
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
|
else
|
||||||
if ! install_pkg virt-what && [ -f /etc/alpine-release ]; then
|
if command -v systemd-detect-virt; then
|
||||||
add_community_repo_for_alpine
|
systemd-detect-virt
|
||||||
install_pkg virt-what
|
else
|
||||||
|
if ! install_pkg virt-what && [ -f /etc/alpine-release ]; then
|
||||||
|
add_community_repo_for_alpine
|
||||||
|
install_pkg virt-what
|
||||||
|
fi
|
||||||
|
virt-what
|
||||||
fi
|
fi
|
||||||
virt-what
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user