From 09b3111d2bd2b9c141551038fee4b601f04ad0ea Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 22 Jun 2023 22:44:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20windows=20=E4=B8=8B?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6=E6=98=AF=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E6=9C=BA=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index fafb389..1836801 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -91,14 +91,21 @@ add_community_repo_for_alpine() { } is_virt() { - if command -v systemd-detect-virt; then - systemd-detect-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 ! install_pkg virt-what && [ -f /etc/alpine-release ]; then - add_community_repo_for_alpine - install_pkg virt-what + if command -v systemd-detect-virt; then + systemd-detect-virt + else + if ! install_pkg virt-what && [ -f /etc/alpine-release ]; then + add_community_repo_for_alpine + install_pkg virt-what + fi + virt-what fi - virt-what fi } @@ -110,8 +117,7 @@ setos() { setos_alpine() { flavour=lts - # 在windows中没有命令判断是否为虚拟机 - if ! is_in_windows && is_virt; then + if is_virt; then # alpine aarch64 3.18 才有 virt 直连链接 if [ "$basearch" == aarch64 ]; then (($("$releasever >= 3.18" | bc))) && flavour=virt